Skip to content

fix: preserve model parsing errors for nullable fields - #1531

Open
Boulea7 wants to merge 1 commit into
openapi-generators:mainfrom
Boulea7:fix/nullable-model-parse
Open

Boulea7 wants to merge 1 commit into
openapi-generators:mainfrom
Boulea7:fix/nullable-model-parse

Conversation

@Boulea7

@Boulea7 Boulea7 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

The generated parser for a Child | None field could return a raw dictionary when Child.from_dict rejected the input. For a missing required field, the caller would first see the failure when reading a child attribute.

A nullable field with one model now handles None and omitted optional values before using the ordinary nested model parser. Invalid object data raises during from_dict. Valid nested models and explicit null values round-trip through the generated client.

I regenerated the original OpenAPI 3.1 report and checked missing IDs, invalid UUIDs and wrong payload types. The regression tests also cover a reversed oneOf, omission and a mixed union with a string variant. All 488 repository tests and five snapshots pass.

Fixes #1525.

OpenAI Codex assisted with the implementation and verification.

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.

Invalid nested object in a nullable field is silently kept as a raw dict

1 participant