Skip to content

Preserve union metadata when collapsing nullable wrappers - #2566

Draft
g-logunov wants to merge 1 commit into
oapi-codegen:mainfrom
g-logunov:feature/fix-nested-nullable-unions-upstream
Draft

g-logunov wants to merge 1 commit into
oapi-codegen:mainfrom
g-logunov:feature/fix-nested-nullable-unions-upstream

Conversation

@g-logunov

@g-logunov g-logunov commented Sep 24, 2026 •

Copy link
Copy Markdown

Fixes #2565.

Nested nullable unions lose their JSON methods and accessors during generation, causing JSON round trips to replace the payload with {}.

Preserve UnionElements and Discriminator in the shared collapseNullableUnion helper so generated types retain their JSON methods, union accessors, and discriminator helpers.

Regression coverage includes client/server round-trip matrix cases under schema-merging-behavior v1, v2, and v3, plus nullable-schema tests for nested anyOf/oneOf, null values, and discriminator accessors. The matrix cases fail against current main and pass with the fix.

Validation: make tidy, make generate, make test, and make lint passed.

@g-logunov
g-logunov force-pushed the feature/fix-nested-nullable-unions-upstream branch from 7c1bc35 to e869693 Compare September 27, 2026 18:35
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.

Nested nullable unions silently discard JSON payloads

1 participant