Skip to content

fix: resolve issue where multi-typed schemas are presumed to be nullable - #59

Open
mwja wants to merge 1 commit into
gpu-cli:mainfrom
mwja:item-typed-multi-null-fix
Open

fix: resolve issue where multi-typed schemas are presumed to be nullable#59
mwja wants to merge 1 commit into
gpu-cli:mainfrom
mwja:item-typed-multi-null-fix

Conversation

@mwja

@mwja mwja commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #58. When type is an array, the first item is always picked and turned into Option<X>, this should not always be the case and it should respect the other variants.

Footnote: type as an array is not valid OpenAPI spec but it is valid JSON schema, which I believe this project also aims to target and I've seen APIs use type arrays in the wild (OpenFoodFacts comes to mind).

Generated compatibility

  • Generated model or method signatures: Breaking, for those depending on the incorrect generated type but not breaking for those only needing Option<X> for [X, null].
  • Query/path/header/body wire behavior: Now correctly respects variants but still respects nullable array types.
  • Remaining unsupported OpenAPI shapes: Disciriminated multi-type unions ( type: [string, integer with enum: [...] do not resolve with the enum for the string variant, though I've never seen this in the wild, only anyOf with the variants. Most online resources (for example https://www.learnjsonschema.com/2020-12/applicator/anyof/) also suggest the latter.

Validation

  • Added or updated a focused fixture and behavioral regression test.
  • Reviewed every changed snapshot; no unrelated churn is included.
  • cargo fmt --check
  • cargo clippy --all-features -- -D warnings
  • cargo test --all-features
  • Ran scripts/install-smoke.sh for packaging/dependency changes.
  • Ran a targeted or full scripts/spec-compile.sh for generator changes.
  • Updated README, rustdoc, or changelog for user-visible behavior.

Notes for reviewers

#58 provides a before and after.

The existing fallback code just took the primary schema and did a
fallback to `Option<X>` but this wasn't necessarily correct.
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

@mwja is attempting to deploy a commit to the lbl-rd Team on Vercel.

A member of the Team first needs to authorize it.

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.

type: [X, Y] multi-type unions (OpenAPI 3.1) collapse to only the first-listed type

1 participant