Skip to content

feat!: use type aliases instead of RootModel for root schemas#51

Merged
damaz91 merged 3 commits into
Universal-Commerce-Protocol:mainfrom
damaz91:feat/avoid-root-model
Jul 10, 2026
Merged

feat!: use type aliases instead of RootModel for root schemas#51
damaz91 merged 3 commits into
Universal-Commerce-Protocol:mainfrom
damaz91:feat/avoid-root-model

Conversation

@damaz91

@damaz91 damaz91 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

This PR modifies the codegen configuration to avoid generating Pydantic RootModel classes for root schemas (schemas that don't define an object at the root, like Amount). Instead, it generates them as PEP 695 TypeAliasTypes combined with Annotated for validation.

This resolves the issue where generated Python SDK classes had fields called root (e.g., Amount.root).

The SDK has been regenerated using UCP schema version 2026-04-08.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, including removal of schema files or fields)
  • Documentation update

Is this a Breaking Change or Removal?

  • I have added ! to my PR title (e.g., feat!: remove field).
  • I have added justification below.

Breaking Changes / Removal Justification

Switching from RootModel classes to type aliases is a breaking change because:

  1. Root types can no longer be instantiated as classes (e.g., PaymentHandler(...) is invalid). Clients must use the underlying primitive types directly.
  2. The .root attribute is no longer available on these types (e.g., checkout_req.fulfillment.root will raise AttributeError).

Downstream conformance tests have been updated in a separate PR to handle this compatibility.


Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (compiled successfully, conformance tests verified with updates)
  • Any dependent changes have been merged and published in downstream modules

damaz91 added 3 commits July 10, 2026 15:00
Avoids generating classes with 'root' fields for schemas that don't define an object at the root (like Amount). Instead, they are generated as TypeAliasType using Annotated with Field for validation.

This is a breaking change for any client code that was instantiating these root models as classes.

TAG=agy
CONV=8eec77fa-d0ae-4394-9976-9a7bafa71f51
@damaz91 damaz91 added status:needs-triage Signal that the PR is ready for human triage status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Jul 10, 2026
@damaz91 damaz91 merged commit b1631ad into Universal-Commerce-Protocol:main Jul 10, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants