Skip to content

MPT-19057: add first-level field annotations to commerce resource models#233

Merged
albertsola merged 1 commit intomainfrom
MPT-19057/commerce-resource-attributes
Mar 16, 2026
Merged

MPT-19057: add first-level field annotations to commerce resource models#233
albertsola merged 1 commit intomainfrom
MPT-19057/commerce-resource-attributes

Conversation

@albertsola
Copy link
Copy Markdown
Contributor

@albertsola albertsola commented Mar 16, 2026

Add typed field annotations (str | None, bool | None, BaseModel | None, list[BaseModel] | None) to all commerce resource Model subclasses:

  • Agreement, AgreementAttachment (agreements.py, agreements_attachments.py)
  • Asset (assets.py)
  • Order (orders.py)
  • OrdersAsset (orders_asset.py)
  • OrderSubscription (orders_subscription.py)
  • Subscription (subscriptions.py)

Fields are derived from openapi-dev.json first-level properties. id is inherited from Model and skipped. $meta is skipped (invalid identifier). camelCase API names are converted to snake_case Python attributes. All fields are | None since no fields appear in the OpenAPI required array.

Add corresponding unit tests for each model covering:

  • primitive field round-trip (to_dict)
  • nested object fields resolved as BaseModel instances
  • optional fields absent when not in input data

Closes MPT-19057

Release Notes

  • Added typed first-level field annotations to commerce resource model classes: Agreement, AgreementAttachment, Asset, Order, OrdersAsset, OrderSubscription, and Subscription.
  • All added fields are optional and use types: str | None, bool | None, BaseModel | None, or list[BaseModel] | None.
  • Field lists were derived from first-level properties in openapi-dev.json; API camelCase names converted to snake_case Python attributes.
  • Inherited id field and $meta property were excluded from annotations.
  • Added comprehensive docstrings describing the new attributes for each resource model.
  • Added unit tests for each model covering:
    • primitive field round-trip serialization via to_dict(),
    • nested object fields resolved as BaseModel instances,
    • absence of optional fields when not provided in input data.
  • Corrected test filename: replaced test_order_subcription.py with test_order_subscription.py.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants