Fix nested intersections in union flattening#2914
Conversation
|
Thanks for the fix! We reviewed it in depth and it looks correct: we reproduced the One request before merging: we'd like the test to be a standard JSON Schema fixture rather than a Vitest unit test, so the fix is exercised across all target languages with a real round-trip plus a negative example. We've prepared that conversion on the branch
Since this PR's head is on an org-owned fork, GitHub doesn't allow maintainer pushes, so to pick it up you can merge it into or cherry-pick 🤖 Generated with Claude Code |
|
One-click option for the fixture conversion mentioned above: I've opened braintrustdata#1 against this PR's |
That is very kind of you! Let me get this updated now |
Replace the Vitest unit test (which checked Rust output strings for one language) with a standard JSON Schema fixture exercising the same shape: an allOf nested inside a oneOf inside another oneOf, taken from the issue glideapps#2913 repro. The fixture runs against every language in CI, round-trips a positive instance, and expects failure on a malformed union member for languages with the "union" feature. Verified end-to-end locally with schema-golang and schema-typescript; all 22 CI target languages generate successfully from the schema. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
Diagnosed the CI failure: only |
…e not checked (known limitation) (#2) cjson's generated parser does not validate invalid types in unions, maps, and arrays (documented above this skip list), so it silently coerces the fixture's expected-failure instance (array where an object is required) into an empty object instead of rejecting it. Skip the schema for cjson, exactly like the existing class-with-additional, go-schema-pattern-properties, and multi-type-enum skips. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
The next CI failure is the same known invalid-type limitation in the C++ renderer: it accepts the new non-object expected-failure input after the nested union is flattened to an all-optional class. Direct maintainer pushes are disabled on this org-owned fork, so I opened braintrustdata#3 with the minimal C++ |
awesome just merged that in. if i can somehow make it easier for you/us to iterate on this, let me know, happy to. eg i can try to run all the tests locally? |
Sorry about all this noise. quicktype's CI stops at the first failure instead of finishing all the tests, so there might still be others failing. Would you mind enabling allowing pushes from us on this PR? |
|
Fixed via #2944 |
Description
Fix union flattening when an intersection is nested inside another union.
FlattenUnionspreviously checked only whether the types being unified were themselvesIntersectionTypeinstances. An intersection nested inside aUnionTypewas therefore passed tounifyTypes, eventually causingInternal error: Unknown type intersection.The fix recursively checks union members for intersections and uses the existing reconstitution path when one is found.
Related Issue
Fixes #2913
Previous Behaviour / Output
Returned an error
New Behaviour / Output
Generates the types
How Has This Been Tested?
Added a unit test with the repro from #2913 and ran it on the full OpenAI OpenAPI spec