You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Emit compact type arrays for JSON Schema unions - #12599
Primitive unions currently emit separate anyOf branches, making schemas more verbose than necessary. Combine unconstrained alternatives into JSON Schema type arrays:
Mixed unions combine compatible types into one branch while preserving constraints, annotations, references, and explicit @oneOf semantics. This changes the emitted structure without changing which values validate.
Emit unconstrained union variants as a compact JSON Schema type array instead of separate anyOf branches, preserving constrained variants and explicit @oneOf behavior.,> ,> For example, value: string | null now emits:,> ,> json,> { "type": ["string", "null"] },>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Recursive union compaction can discard an unresolved reference and emit an overly permissive schema that incorrectly accepts {}, requiring a resolution-aware fix and regression test.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Union compaction changes validation semantics when union- or property-level extensions override structural keywords, allowing booleans that the previous schema rejected.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve union validation when extensions override structural schema keywords
Returning the compact schema changes validation when a union or its containing property has @extension("type", "boolean"): for value: string | null, the previous schema retained anyOf alongside type: "boolean" and rejected every value, whereas the new schema becomes just type: "boolean" and accepts booleans because #applyConstraints overwrites type (lines 783–789). Preserve the original combinator when union/property extensions override structural keywords such as type or anyOf, and add regression coverage for both scopes.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Union compaction changes validation behavior when type or anyOf extensions override the emitted schema, requiring preservation of the original anyOf structure and regression tests at union and inline-property scopes.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve union validation when extensions override type or anyOf
@extension("type", "number") union Value { integer, null } now accepts 1.5: #applyConstraints overwrites the compacted type at lines 783–789, whereas the previous anyOf still rejected it. An anyOf override can instead reject previously accepted values, and both regressions also affect extensions on inline-union properties. Preserve the original anyOf structure when the union or containing property overrides type or anyOf, and add regressions for both keywords at both scopes.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Union compaction leaves conflicting type and anyOf constraints when extensions override either keyword, rejecting previously valid values and affecting inline union properties.
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
The JSON Schema union-compaction change has no active review issues.
No open issues 🎉
Review effort: Balanced
This branch has not been deployed
No deployments
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
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.
Primitive unions currently emit separate
anyOfbranches, making schemas more verbose than necessary. Combine unconstrained alternatives into JSON Schematypearrays:Mixed unions combine compatible types into one branch while preserving constraints, annotations, references, and explicit
@oneOfsemantics. This changes the emitted structure without changing which values validate.Fixes #2656.