fix: preserve array-root request variants#52
Open
ShuoRen-TT wants to merge 1 commit into
Open
Conversation
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix request variant generation for array-root schemas such as
totals.json._create_single_variantpreviously injected emptypropertiesandrequiredmembers into every generated variant. For an array-root schema,
datamodel-code-generator interpreted the resulting mixed array/object shape as
a union between the intended list and an empty
BaseModel. The function alsodid not apply nested
ucp_requestrules underitemsand itsallOfbranches.This change:
items;validation.
The generated totals request aliases are now lists of
Total. They no longercontain a spurious empty model or expose the nested response-only
linesfield as a typed request field.
Relationship to #35
This PR and #35 are complementary rather than competing fixes.
$refrewriting for top-level compositionbranches such as
oneOfandanyOf.ucp_requestfiltering under
itemsandallOf.Both changes touch
_create_single_variant, so the PR merged second may need asmall mechanical rebase. This PR intentionally does not include #35's
whole-variant
$refrewrite or its generated fulfillment model changes.Category (Required)
ucp-schematool (resolver, linter, validator). (Requires Maintainer approval)Related Issues
Fixes #37
Related: #35
Checklist
generate_models.sh 2026-04-08.Validation
bash generate_models.sh 2026-04-08python -m unittest preprocess_schemas_test.py(2 tests passed)python -m compileall -q preprocess_schemas.py preprocess_schemas_test.py src/ucp_sdk