fix(compilers/openapi): reconcile allOf branches that redeclare a field - #8
Merged
Merged
Conversation
An allOf whose inline branches redeclare the same property was lowered by appending every branch's properties into one model, producing multiple properties that share a wire name. The validate pass then correctly flagged the corrupted model, raising hundreds of spurious duplicate-wire-name errors (304 on the GitHub REST API spec, where webhook `forkee`, `issue`, and `workflow_job` schemas use an allOf of a documented object plus a doc-stripped duplicate that marks some fields required). allOf is an intersection: a redeclared field is one logical property, required when any branch requires it. Reconcile same-wire-name properties into a single property — OR-ing Required, with the first (richest) declaration defining the shape — instead of appending duplicates.
This was referenced Jul 20, 2026
…roperty fillModelProperties always sets a non-empty WireName, so the Name.Source fallback branches were dead code and left the package below the 100% coverage gate. Compare WireName directly.
OmarAlJarrah
force-pushed
the
fix/openapi-allof-property-reconcile
branch
from
July 20, 2026 17:44
94bf8ad to
6971ef5
Compare
…ly OR-ing required Reconciling an allOf field that is redeclared across branches previously combined only Required and kept the first declaration's shape wholesale, so any type detail on a later branch — a default, constraints, deprecation, XML hints, examples — was silently dropped, and the surviving shape depended on branch order. Make reconciliation a proper intersection: OR Required and Secret, and adopt each optional detail the surviving property lacks from the redeclaration, so a documented declaration and a bare one reconcile to the richer property whatever their order. A genuinely conflicting redeclared description (both present and different) is reported as an info diagnostic rather than dropped without trace. Index properties by wire name so a redeclaration reconciles in one lookup rather than rescanning, keeping property fill linear for wide models.
This was referenced Jul 22, 2026
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 hundreds of spurious
pass/duplicate-wire-nameerrors when compilingspecs whose
allOfschemas have inline branches that redeclare the same field.allOflowering appended every inline branch's properties into one model. Whentwo branches declared a property with the same name — a common real-world shape
where a documented object is followed by a doc-stripped duplicate that marks
some fields required — the model ended up with several properties sharing one
wire name. The validate pass then correctly flagged that corrupted model.
On the GitHub REST API spec this produced 304 errors across
forkee,issue,workflow_job,project_card,author, andcommitterschemas(e.g.
webhook-fork/properties/forkeealone had 168 properties, 78 duplicated).allOfis an intersection: a redeclared field is one logical property, presentif the instance satisfies every branch and required if any branch requires it.
The fix reconciles same-wire-name properties into a single property (OR-ing
Required, first declaration defining the shape) instead of appendingduplicates. Ref/mixin classification (ir-design §4.3) is unchanged.
Test plan
TestAllOf_OverlappingInlineBranchesReconcile— two inline branchesredeclaring a field reconcile to one property;
Requiredreflects thebranch that requires it; the documented declaration defines the shape.
go test ./...— all packages pass (golden snapshots unchanged).304 errors -> 0; only the pre-existing240 benign
openapi/degraded-constructinfo diagnostics remain; exit code 0.