Skip to content

fix: reuse duplicate capability extension models#56

Merged
damaz91 merged 2 commits into
Universal-Commerce-Protocol:mainfrom
ShuoRen-TT:fix/reuse-duplicate-capability-models
Jul 16, 2026
Merged

fix: reuse duplicate capability extension models#56
damaz91 merged 2 commits into
Universal-Commerce-Protocol:mainfrom
ShuoRen-TT:fix/reuse-duplicate-capability-models

Conversation

@ShuoRen-TT

Copy link
Copy Markdown
Contributor

Summary

  • enable datamodel-code-generator model reuse during SDK generation
  • regenerate capability aliases so repeated constraints reference canonical definitions
  • add a dependency-free regression test for the generated compatibility aliases

Motivation

Schema preprocessing expands the inline capability extends union into several structurally identical anonymous schemas. Without model reuse, code generation repeats the same string constraints across the numbered Extends* aliases.

This enables the --reuse-model option recommended in #36. Existing numbered aliases remain importable and preserve their validation behavior; this deliberately does not enable --collapse-reuse-models, which would remove those compatibility names.

Validation

  • python -m unittest discover -s tests -p "test_*.py" on Python 3.10, 3.11, and 3.12: 14 tests passed on each version
  • regression test fails against the previous generated output and passes after regeneration
  • two consecutive ./generate_models.sh 2026-04-08 runs produced the same capability.py SHA-256
  • targeted Ruff format and lint checks passed
  • bash -n generate_models.sh passed
  • runtime validation confirmed the reused string and list aliases retain their Pydantic semantics

Related work

#55 also touches generate_models.sh but addresses minProperties enforcement. There is no functional dependency or overlap beyond that file.

Fixes #36

@ShuoRen-TT ShuoRen-TT marked this pull request as ready for review July 16, 2026 08:04
@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 16, 2026
@damaz91 damaz91 merged commit 73844ee into Universal-Commerce-Protocol:main Jul 16, 2026
15 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.

Codegen emits 8 duplicate Extends* classes in capability.py

2 participants