fix: resolve issue where multi-typed schemas are presumed to be nullable - #59
Open
mwja wants to merge 1 commit into
Open
fix: resolve issue where multi-typed schemas are presumed to be nullable#59mwja wants to merge 1 commit into
mwja wants to merge 1 commit into
Conversation
The existing fallback code just took the primary schema and did a fallback to `Option<X>` but this wasn't necessarily correct.
|
@mwja is attempting to deploy a commit to the lbl-rd Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Fixes #58. When
typeis an array, the first item is always picked and turned intoOption<X>, this should not always be the case and it should respect the other variants.Footnote:
typeas 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 usetypearrays in the wild (OpenFoodFacts comes to mind).Generated compatibility
Option<X>for[X, null].type: [string, integerwithenum: [...]do not resolve with the enum for the string variant, though I've never seen this in the wild, onlyanyOfwith the variants. Most online resources (for example https://www.learnjsonschema.com/2020-12/applicator/anyof/) also suggest the latter.Validation
cargo fmt --checkcargo clippy --all-features -- -D warningscargo test --all-featuresscripts/install-smoke.shfor packaging/dependency changes.scripts/spec-compile.shfor generator changes.Notes for reviewers
#58 provides a before and after.