Repository navigation
fix(sdk-generator): deserialize ref-or-object union responses in Python - #124
Merged
Merged
Conversation
Python generation threw for GET /orgs/{org}/task_epics, whose 200 is a
union of an inline summary object and a $ref collection (selected by the
representation query param). Add a model_union response shape validated as
`Model | dict[str, Any]`; Go and Swift keep treating it as untyped JSON.
Pure $ref unions still fail generation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Regenerating archastro-python from the refreshed platform spec (#121) fails:
GET /api/v1/orgs/{org}/task_epicsreturns a union of an inline summary object and a$refcollection (chosen by therepresentationquery param).pythonResponseShapedeliberately throws for refs buried in unions, so Python generation aborts.Change
model_unionshape for unions that mix at least one$refand at least one plain object. The runtime validates againstModel | dict[str, Any](refs first); contract tests assertBaseModelordict.model_uniontountyped(JSON value), unchanged in behavior for them.$ref | $refunions still fail generation (existing test untouched).Scope / risk / testing
Generator only; Python/Go/Swift backends read the shared classifier. Low-medium risk. New unit test for the shape and the
response_typeexpression. Localnpm run build,npm run lint,npm testpass. Verified end to end: regenerated archastro-python with this build; ruff clean, unit tests pass, 3564 contract tests pass.🤖 Generated with Claude Code