Skip to content

fix(sdk-generator): deserialize nullable $ref responses - #85

Merged
calvin-archastro merged 2 commits into
mainfrom
fix/nullable-ref-response-shape
Aug 18, 2026
Merged

fix(sdk-generator): deserialize nullable $ref responses#85
calvin-archastro merged 2 commits into
mainfrom
fix/nullable-ref-response-shape

Conversation

@calvin-archastro

@calvin-archastro calvin-archastro commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Review on ArchCode

Problem and author intent

GET /api/v1/tasks/{task}/lease is allOf: [$ref] + nullable. Python, Go, and Swift share pythonResponseShape, which treated any non-ref/array/object return as undeserialized and aborted generation. Official Python regen failed on that check.

What changed

Unwrap outer nullable/optional before classifying. Inner $ref still deserializes as a model; JSON null is accepted (Model | None, *Model, Model?). Contract tests accept None or the model.

Scope

backend-only (generator). No user-facing product change.

Risk

low. Classifier change is covered by a fixture that is the lease shape.

Testing

npm test --workspace=@archastro/sdk-generator -- __tests__/backends/python.test.ts — 149 passed. Canonical proof: deserializes nullable $ref responses as Model | None.

GET /tasks/{task}/lease is allOf+$ref+nullable. Python/Go/Swift
classified that as an undeserialized shape and aborted generation.
Unwrap outer nullability so the inner model still deserializes,
and accept JSON null at runtime.
Join methods type inline objects as [String: JSONValue]. Contract
tests were constructing hoisted LocalToolsItem structs that do not exist.
@calvin-archastro
calvin-archastro merged commit 184cf05 into main Aug 18, 2026
3 checks passed
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.

1 participant