fix(generator): preserve union input and nullable results - #83
Merged
Merged
Conversation
…on branch Union deserializers keep a branch only if re-serializing it reproduces the input. An integer in a `number` field (re-encoded as `1.0`) and an explicit `null` for an optional field (skipped on output) both failed that check, so every Cloudflare DNS record was rejected. oneOf compared with strict equality, and anyOf treated an input null as lost. Both now fall back to a comparison that treats those encodings as equal, but only when no branch reproduces the input exactly, so inputs that decoded before keep their branch and ambiguity is still reported.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Treat nullable anyOf branches as admitting null and respect oneOf uniqueness when inferring property nullability. Cover Cloudflare-style required null results and refresh generated corpus expectations.
Compile generated scratch crates without debug symbols or incremental artifacts so Cloudflare can fit on a standard GitHub runner.
This reverts commit 27a215e.
8 tasks
This branch was successfully deployed
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
This branch starts from #82 and retains @gilesw's original commits. It fixes two issues found while reviewing and running the full corpus:
oneOf/anyOffallback no longer accepts a branch that adds a serialized key. A required, defaultedmodefield previously accepted{}and re-encoded it as{"mode":""}.anyOfbranches allownullis now generated as nullable. Cloudflare returned validresult: nullvalues that the previous Rust model could not deserialize. ForoneOf, the property admitsnullonly when exactly one branch does.Generated-runtime regressions, existing union expectations, and the 56-spec corpus manifest are updated. This PR can replace #82 as the merge candidate; it includes all three commits from that PR.
Verification
scripts/spec-compile.sh: 55 passed, 0 generation/compile/roundtrip failures; 28,139 of 29,045 component schemas exercised with 103,031 samples. Gitea was skipped as Swagger 2.0. Microsoft Graph generated successfully but is generate-only in this script.cargo checkof the generated Microsoft Graph crate passed on a machine with sufficient memory.The manual GitHub full-spec job stopped with exit 143 during Cloudflare in three attempts, without a Rust diagnostic. Removing debug symbols and incremental artifacts did not resolve it, so that workflow experiment was reverted. The runner-capacity issue is tracked as
openapi-generator-bh9; the successful local full run provides the complete compile result for this PR.Tracking
The correctness fixes are tracked as
openapi-generator-b2yandopenapi-generator-v1s. Consolidating the repeated generated comparison helper is tracked asopenapi-generator-wwr.