Skip to content

fix(what-changed): keep the direction of schemas in exclusive unions - #727

Open
frederikprijck wants to merge 19 commits into
pb33f:mainfrom
frederikprijck:fix/what-changed-oneof-response-usage
Open

frederikprijck wants to merge 19 commits into
pb33f:mainfrom
frederikprijck:fix/what-changed-oneof-response-usage

Conversation

@frederikprijck

@frederikprijck frederikprijck commented Nov 23, 2026 •

Copy link
Copy Markdown

Fixes #726.

Problem

Since #725, a required entry added to an open schema that only responses use is not reported as breaking. That does not apply inside a oneOf: the usage walk marks every branch as used by both requests and responses (schema_usage.go#L266-L267), while allOf and anyOf keep the direction of the enclosing schema.

Being careful with oneOf makes sense in general. A oneOf rejects an instance that matches more than one branch, so changing one branch can change what the union accepts: widening a branch can make an instance match a second one, and narrowing it can leave an instance that matched two branches with only one. That cannot happen when no instance can match two branches. Then oneOf is equivalent to anyOf.

Change

A oneOf keeps the direction of the enclosing schema when no instance can match two of its branches:

  • there is a single branch, or
  • the branches accept different types.

The type check follows chains of $ref and stops at a reference it has already followed. OpenAPI 3.0 ignores the siblings of $ref, so there only the referenced schema counts. In 3.1 they apply as well, so a type next to a $ref narrows the branch. That only happens when the version is known to be 3.1 or later and TransformSiblingRefs is on (the default), because without TransformSiblingRefs the schema model does not read the siblings either. It also only happens next to the $ref of the branch itself, written in place, because that is the only place the model reads it: when the model reaches a schema through a $ref it follows the $ref of that schema and drops the type next to it, and it does the same for a branch that is a YAML alias. Otherwise only the referenced schema counts. A $ref to true narrows nothing, like {}.

It reads type and nullable the way the schema model does: a single type only from a YAML string, a type list by its items, and nullable from any YAML boolean. nullable only adds null in OpenAPI 3.0, or when the version is unknown. It only accepts the JSON Schema type names and treats integer and number as overlapping.

The schema model itself read an alias in a type list as its anchor name (type: [*object] became object). It now reads the value the alias points to, as it already did for a single type, so Schema.Type, its hash and the rendered output change for such lists.

Everything else stays shared as before: branches with overlapping types, branches without a type, a type name it does not know, an empty list of types, boolean branches, a $ref to false, a type next to a $ref that has nothing in common with the referenced schema, and a branch whose $ref value is a YAML alias, which the model does not resolve. A reference that cannot be resolved makes the usage of the whole document unknown, as before.

The check only runs when the enclosing direction is not already shared, because it cannot change a shared one.

Because the direction is kept, this applies to requests as well: a required entry removed from a schema in an exclusive union that only requests use is not reported as breaking either.

Keywords the model drops next to a $ref

The walk follows the keywords next to a $ref, as it does on main, but the model does not always read them. It drops them without TransformSiblingRefs, when it reaches a schema through a $ref, for an alias in a list, and always next to the $ref of a response, request body, parameter, header or path item. It also does not resolve a $ref whose value is an alias. The walk can therefore give a schema a direction that the model does not have. On main that did not matter inside a oneOf, because every branch was shared, but an exclusive union could make it matter.

The walk now records whether it reached a schema through something the model does not read, and whether it kept the direction of a oneOf. When both happen, the document is walked again with every oneOf shared, and only what that walk reaches through those keywords is added to the usage, so a schema keeps the direction it had on main. A schema that is reached both where the model reads the keywords next to a $ref and where it drops them is walked for both. Nothing tells what the model leaves out around a $ref whose value is an alias, so there everything the second walk reaches counts, which is the usage of main. Documents without such keywords keep the direction of their exclusive unions. In OpenAPI 3.0 the model still reads the keywords next to a $ref where the schema is written, so treating them as dropped there only shares more unions.

Tests

  • New schema_usage_oneof_test.go covers:
    • exclusive unions that are relaxed, in responses and requests: single branch, distinct types, type lists, references and chains of them, nullable in 3.0 and 3.1, and a narrower type next to a $ref in 3.1;
    • unions that must stay breaking: overlapping or missing types, unknown type names, a boolean branch or a $ref to false, $ref siblings the model does not read (3.0, TransformSiblingRefs off, along a chain, in an alias), and nullable branches in 3.0 in any YAML spelling;
    • keywords the model drops next to a $ref, which share the unions they reach again, including a schema reached both in place and through a $ref in either order, and a $ref whose value is an alias;
    • a keyword written as an alias key (*kind: string), and an alias in a list of types that keeps each use;
    • the alias and true cases after rendering and reparsing.
  • TestSchema_Build_TypeListWithAlias in datamodel/low/base.
  • TestRequiredConservativeSchemaContexts: oneOf with a single branch now expects "not breaking".
  • go test ./... passes, and the reproduction from what-changed: required property added to a response-only schema is reported as breaking when used inside oneOf #726 reports 0 breaking for 03-oneof, with the other two cases unchanged.

Performance

  • The usage maps for the OpenAPI 3 fixtures in test_specs/ (including Stripe, DocuSign and Asana) are identical to main.
  • On its own, the usage walk takes about 3–11% longer on those documents, with the same allocations. A synthetic walk over 128 unions takes about 30% longer (about 20 µs to 26 µs).
  • BenchmarkPipeline_Compare_Stripe shows no measurable difference (about 280 ms on both).

Not covered

Branches of the same type that are told apart by const or enum, as in many discriminated unions, stay shared. Proving those branches exclusive would need a different analysis.

In OpenAPI 3.0 a type next to a $ref never narrows a branch. With TransformSiblingRefs on, the model does read it where the schema is written, so the check is more conservative than the model there. OpenAPI 3.0 says those siblings are ignored, so a tool that follows the spec sees {$ref: Untyped, type: string} as accepting anything.

A discriminator anywhere in a document makes the usage of the whole document unknown (#728). Such documents get neither this relaxation nor the one from #725 until that is fixed.

Note

#729 changes the same part of schemaField and walkReached, and adds fields to usageWalker and functions in the same place, so whichever of the two is merged second has conflicts in schema_usage.go. Each one is resolved by keeping both changes. When the first one is merged, I will resolve it in the second one with a merge commit. #729 reads the keywords next to a $ref whenever TransformSiblingRefs is on, while this PR only narrows by them in 3.1 or later, so the two need to agree on that before both are merged.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b9309bc) to head (67055f0).
⚠️ Report is 40 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main      #727     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          316       324      +8     
  Lines        40280     41876   +1596     
===========================================
+ Hits         40280     41876   +1596     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frederikprijck
frederikprijck force-pushed the fix/what-changed-oneof-response-usage branch from 275207e to 87b154d Compare November 23, 2026 10:18
@frederikprijck frederikprijck changed the title fix(what-changed): keep the response use of schemas in exclusive unions fix(what-changed): keep the direction of schemas in exclusive unions Nov 23, 2026
frederikprijck and others added 2 commits November 23, 2026 15:14
A oneOf accepts an instance only when exactly one branch matches, so the usage
walk treated every branch as used by both requests and responses. A required
entry added to a schema that only responses use stayed breaking whenever the
schema sat in a oneOf.

Branches that cannot match the same instance, because their types are disjoint
or because there is a single branch, cannot interfere with each other, so they
now keep the direction of the oneOf, as anyOf does. Branches that overlap, that
do not state a type, or that mix integer and number keep the shared result.

Co-Authored-By: Claude <noreply@anthropic.com>
OpenAPI 3.0 ignores the siblings of $ref, so a branch such as
{$ref: Other, type: string} accepts what Other accepts. The exclusivity check read
the sibling type first, so it could treat overlapping branches as exclusive and
relax a change that can break a client. The check now follows the reference
first, which is an upper bound in 3.0 and in 3.1.

It also only accepts the JSON Schema type names, so an unknown name such as
Object no longer counts as a distinct type, and duplicate types inside one branch
no longer count as an overlap.

Exclusive branches keep the direction in requests as well, so a required entry
removed from a request-only union is not breaking either. Tests now cover that,
OpenAPI 3.0 documents, and the cases above.

Co-Authored-By: Claude <noreply@anthropic.com>
@frederikprijck
frederikprijck force-pushed the fix/what-changed-oneof-response-usage branch from 2acbdc9 to 8969ccb Compare November 23, 2026 14:15

@daveshanley daveshanley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing #726. I verified that the original array/object example now reports zero breaking changes, and the full Go suite passed. I’d fix the YAML type and nullable handling before merging.

Comment thread what-changed/model/schema_usage.go Resolved
Comment thread what-changed/model/schema_usage.go Resolved
Comment thread what-changed/model/schema_usage.go Resolved
Comment thread what-changed/model/schema_usage.go Resolved
Comment thread what-changed/model/schema_usage.go Resolved
frederikprijck and others added 5 commits November 26, 2026 09:16
… already shared

When the enclosing direction is already shared, the branches get the same
direction whether they are exclusive or not, so checking them only costs
allocations. Webhooks and callbacks are always shared, and with 128 webhook
unions the usage walk went from 72 allocations to 840. The check now only runs
when its result can change the direction, which brings it back to 72.

Co-Authored-By: Claude <noreply@anthropic.com>
…n OpenAPI 3.0

The exclusivity check compared the text of nullable with "true", while the
schema model accepts any YAML boolean and parses it with strconv.ParseBool. A
branch with nullable: True or TRUE was not seen as accepting null, so two
nullable branches could look exclusive and a breaking change was not reported.
A quoted 'true' went the other way: the model ignores it, the check did not.

OpenAPI 3.1 removed nullable, so it no longer adds null there. When the
version cannot be resolved, nullable still adds null, which can only make the
result less precise and never hides a breaking change.

Co-Authored-By: Claude <noreply@anthropic.com>
…ore nullable on an empty type list

The schema model only reads a single type from a YAML string, so an unquoted
type: null declares no type and the branch accepts any instance. The
exclusivity check read the scalar text as the type name "null", so the branch
looked exclusive with an object branch and a breaking change was not reported.

An empty list of types already meant that the types cannot be compared, but
nullable turned it into "only null". It now stays unknown with or without
nullable.

Items of a type list are still read by their text, as the schema model reads
them: type: [null] is "null" there as well.

Co-Authored-By: Claude <noreply@anthropic.com>
The exclusivity check gave up after following eight references, so a branch
behind seven references was compared by type and the same branch behind eight
was not, which changed the result. It now records the nodes it follows and
stops at one it has seen before, so the length of a chain no longer matters
and a cycle still falls back. The record has room for eight nodes and does
not escape, so common chains do not allocate.

Co-Authored-By: Claude <noreply@anthropic.com>
… in OpenAPI 3.1

In OpenAPI 3.1 the keywords next to $ref apply as well, so a type next to a
reference narrows what the branch accepts. The exclusivity check only read
the referenced schema, so {$ref: X, type: string} with X accepting strings and
objects overlapped with an object branch, while the same branch written inline
did not. The types along the reference chain are now intersected, which also
gives a type to a reference whose target declares none.

This only applies when the version is known to be 3.1 or later and
TransformSiblingRefs is on, because that is the only configuration in which the
schema model reads the siblings too. Without it, the model reads only the
reference, and so does the check. OpenAPI 3.0 ignores the siblings, so nothing
changes there.

Types along the references that have nothing in common, such as a reference to
an object next to type: string, accept no instance at all. That is more likely
a mistake than a schema, so the branch stays unknown instead of being treated
as exclusive. A type next to a reference that cannot be read makes the branch
unknown as well.

Co-Authored-By: Claude <noreply@anthropic.com>
@frederikprijck

frederikprijck commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

Thanks for the review.

I applied the fixes in separate commits (1 per comment, so we can more easily iterate or revert if needed), I also updated the PR description to reflect the changes we made.

I will leave the resolution of the comments to you so you can confirm the fix before we resolve the comment.

@daveshanley daveshanley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes in 1f3e4942. The #726 example now reports zero breaking changes. I also verified the nullable spellings, the longer reference chains, and the return to 37 allocations on the 128-union webhook fixture.

I’m requesting changes before merge. Rendering and reparsing the same documents can still change the breaking count. Please make type-list aliases consistent across the walker and model, and preserve the sibling type when a 3.1 reference points to true. Alias round trip · Boolean reference target

frederikprijck and others added 2 commits November 27, 2026 14:54
An alias node keeps the name of its anchor as its value, and the schema model
read each item of a type list from that value. With x-type: &object string,
type: [*object] was read as object instead of string, so the schema hashed
differently from type: [string] and rendered as type: [object].

The exclusivity check of a oneOf already followed the alias, so a branch read
as string there while the model stored object. Requiring a property of an
object branch next to it was not breaking, but became breaking once both
documents were rendered and read back. The model now follows the alias as
well, as it already does for a single type and for an alias to a whole list.

Co-Authored-By: Claude <noreply@anthropic.com>
…e type next to it

The boolean schema true accepts every instance, as {} does. In OpenAPI 3.1 a
reference to {} next to type: string was read as a string branch, but a
reference to true made the branch unknown, because the check gave up on any
target that is not a mapping. Requiring a property of an object branch next
to it was therefore breaking with true and not with {}.

A reference to true now narrows nothing, like {}. The boolean schema false
accepts nothing, which is more likely a mistake than a branch that no instance
matches, so it still makes the branch unknown, as types that have nothing in
common do.

Co-Authored-By: Claude <noreply@anthropic.com>
@frederikprijck

Copy link
Copy Markdown
Author

Marking as draft, found a few things I want to look at first.

@frederikprijck
frederikprijck marked this pull request as draft November 27, 2026 15:19
frederikprijck and others added 2 commits November 27, 2026 17:28
…ds next to its $ref

In OpenAPI 3.1 with TransformSiblingRefs, the check read the type next to every
$ref along the chain of references of a branch, and next to the $ref of a
branch that is an alias. The schema model reads neither. When it reaches a
schema through a $ref, it follows the $ref of that schema and drops the type
next to it. The sibling transform skips an alias in a list, so an aliased
branch is read the same way. It does not resolve a $ref whose value is an
alias at all.

With Narrowed: {$ref: StringOrObject, type: string}, the model reads a branch
{$ref: Narrowed}, or an alias of Narrowed, as [string, object], which overlaps
an object branch. The check read it as string, so requiring a property of the
object branch was not breaking. It is breaking on main, where every oneOf
branch is shared.

The type next to a $ref now only narrows the branch itself, written in place.
A branch whose $ref value is an alias cannot be told apart from the others. A
type along the chain that has nothing in common with the referenced schema no
longer makes the branch unknown either, because the model does not read it.

The test for a type next to a reference along the chain now expects a breaking
change. New tests cover a type along the chain that has nothing in common with
the referenced schema, a branch that is an alias, and a branch whose $ref value
is an alias.

Co-Authored-By: Claude <noreply@anthropic.com>
…odel does not read

The walk follows the keywords next to a $ref, as it does on main. The schema
model drops them without TransformSiblingRefs, when it reaches a schema through
a $ref, for an alias in a list, and always next to the $ref of a response,
request body, parameter, header or path item. It also does not resolve a $ref
whose value is an alias, which the walk follows. The walk can therefore give a
schema a direction that the model does not have. On main that did not matter
inside a oneOf, because every branch was shared.

With this PR, an exclusive union could make it matter, for example:

- a oneOf next to the $ref of Holder: {$ref: Other, oneOf: [...]} reached
  through a $ref, or in the keywords next to it,
- an exclusive branch that leads to such keywords,
- a union in the content next to the $ref of a response,
- Holder reached in the response direction outside a union before the walk
  reaches it in an exclusive branch, so that the branch skips it.

Requiring a property of a schema that only those keywords reach was then not
breaking, while it is breaking on main.

The walk now records whether it reached a schema through what the model does
not read, and whether it kept the direction of a oneOf. When both happen, the
document is walked again with every oneOf shared, which gives the same usage
as on main, whatever the order. Documents without such keywords keep the
direction of their exclusive unions. In OpenAPI 3.0 the model still reads the
keywords next to a $ref where the schema is written, so treating them as
dropped there only shares more unions.

Tests cover a oneOf written next to a $ref, next to a $ref reached through a
$ref, in the keywords next to it, in an alias, and such keywords in an
exclusive branch, with the transform on and off. Others cover a reference to
Holder before and after the union, a union next to the $ref of a response and
of a path item, and a $ref whose value is an alias elsewhere, each with a
document without such keywords that keeps the direction.

Co-Authored-By: Claude <noreply@anthropic.com>
@frederikprijck

frederikprijck commented Nov 27, 2026 •

Copy link
Copy Markdown
Author

Since your last review I found that the check could rely on things the schema model does not read. I fixed that in two commits:

  • c3e2e9c: a type next to a $ref now only narrows a branch where the model reads it, which is next to the branch's own $ref, written in place. A type further along a chain of references, on a branch that is a YAML alias, or behind a $ref whose value is an alias no longer narrows the branch.
  • 5ad6dfb: the walk still follows keywords next to a $ref that the model drops, and $ref values that are aliases, as on main. The model drops those keywords without TransformSiblingRefs, for a schema reached through a $ref, for an alias in a list, and next to the $ref of a response or path item. If the walk follows such keywords anywhere and has also made a oneOf exclusive, the document is walked again with every oneOf shared, which gives the same result as main. Documents without such keywords keep their exclusive unions.

Open question: in OpenAPI 3.0 the check ignores a type next to a $ref, as you asked. With TransformSiblingRefs on, the model does read it in 3.0 where the schema is written, so in 3.0 the check is more conservative than the model. Should it follow the model there? This also affects #729, which reads those keywords whenever TransformSiblingRefs is on, so the two PRs need to agree before both are merged.

@frederikprijck
frederikprijck marked this pull request as ready for review November 27, 2026 16:52

@daveshanley daveshanley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Frederik. The original #726 fixture now reports two changes and zero breaking changes. The earlier type-list alias and $ref to true cases pass too.

w.throughDropped = true
}
visited := w.visited[object]
if prior, seen := visited[node]; seen && prior&dir == dir {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got 0 breaking changes for making Widget.id required with /inline first, and 1 with /pointer first. /inline has properties beside a $ref in its response schema, and /pointer references that same schema. Could we track inline and referenced visits separately here so both path orders give the same result?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in db77e26

Comment thread what-changed/model/schema_usage.go Outdated
// The walk follows the keywords the model drops next to a $ref, as it did before. That did not matter while every
// oneOf was shared, so the document is walked again that way when both happen.
if !w.unknown && w.madeExclusive && w.throughDropped {
w = walk(true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the same /notes response to both sides of the #726 fixture takes the breaking count from 0 to 1. Its schema has properties beside a $ref and never references Widget. Could we limit the fallback to the schemas and unions affected by those dropped keywords?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d920650

Comment thread what-changed/model/schema_usage.go Outdated
var declared *yaml.Node
ref := ""
nullable := false
for key, value := range usageFields(node) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With x-label: &kind type and Other: {*kind: string}, the walker reads Other as a string. The low model leaves its type empty. In a response oneOf with Widget and Other, making Widget.id required gives 0 breaking changes before rendering and 1 after reparsing. Could both paths use the same lookup for schema keywords?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 58aff3f

Comment thread datamodel/low/base/schema_build.go Outdated
Value: typeValue.Content[r].Value,
ValueNode: typeValue.Content[r],
Value: item.Value,
ValueNode: item,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolving item.Value fixes the type name. With two uses of *word on lines 7 and 8, GetValueNode() now points both to the anchor on line 3. Could we keep item.Value for Value and store typeValue.Content[r] in ValueNode so diagnostics point to each use?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8a5936f

Comment thread what-changed/model/schema_usage.go Outdated
if nullable && w.nullable {
names = append(names, "null")
}
types := make(map[string]bool)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a response with 128 oneOf properties sharing the same string and integer $refs, the usage walk went from 23.5 to 75.3 µs, 37 to 806 allocations, and 20.4 to 88.5 KiB per walk (8 runs per revision). Building a seven-bit type mask directly from the YAML nodes brought it to about 37 µs and 38 allocations. Could we use that mask here and add a required change to the Stripe benchmark so it exercises this walk?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e6ea366

frederikprijck and others added 3 commits November 30, 2026 09:06
…lue node

Reading the node an alias points to for the type name made GetValueNode()
point every use of the same anchor to the anchor itself, so two uses of
`*word` reported the same position. Keep the name from the node the alias
points to and the node of the use, so diagnostics point to each use.

Co-Authored-By: Claude <noreply@anthropic.com>
… their key

The schema model finds a keyword by the text of its key, so an alias used as
a key (`*kind: string` with `&kind type`) is not the keyword it points to.
The usage walk resolved it, read a type the model leaves empty, and kept the
direction of a oneOf the model treats as shared: 0 breaking changes before
rendering and 1 after reading the document back.

Read type, $ref and nullable of a branch the way the model does.

Co-Authored-By: Claude <noreply@anthropic.com>
Reading the types of each branch built a slice of names and a map of types
for every branch, which took the usage walk of a response with 128 oneOf
properties sharing the same string and integer references from 43 to 812
allocations. Build a seven-bit mask directly from the YAML nodes instead:
44 allocations and about half the time on that fixture.

Add a benchmark for that walk, and a required entry to the Stripe
comparison benchmark so it exercises the walk.

Co-Authored-By: Claude <noreply@anthropic.com>
frederikprijck and others added 5 commits November 30, 2026 09:14
…ently the second time

A schema whose keywords sit next to a $ref is read in place by the model, but
only the $ref is read when the schema is reached through a reference or an
alias. The walk skipped the second visit because the schema had already been
visited, so whether it noticed the keywords the model drops depended on which
path came first: making Widget.id required gave 0 breaking changes with the
inline response first and 1 with the reference first.

Remember the schemas with sibling keywords next to a $ref that were walked in
place, and walk such a schema once more when it is reached where the model
drops them. The $ref scan now shares the loop that already looks for
unevaluatedProperties.

Co-Authored-By: Claude <noreply@anthropic.com>
…drops reach

When the walk followed keywords the model drops next to a $ref and also kept
the direction of an exclusive oneOf, the whole document was walked again with
every oneOf shared. A response that merely has such keywords therefore turned
an unrelated change into a breaking one: adding the same /notes response, with
properties next to a $ref, to both sides made requiring Widget.id breaking
although the response never reaches Widget.

Keep the walk that keeps exclusive unions, and track the visits made inside
those keywords apart from the others. When both happen, walk the document
again with every oneOf shared and add only what that reaches through the
keywords the model drops, which is what a schema reached that way had before
unions were exclusive. A union elsewhere keeps its direction.

Co-Authored-By: Claude <noreply@anthropic.com>
… alias

The model does not resolve a $ref whose value is an alias. It reports an error
and leaves out parts of the operation that has one, such as its responses. The
previous commit only counted what the walk reaches through that $ref as dropped,
so a union in the same operation was kept exclusive although the model may never
read it: requiring Widget.id was not breaking, while it is breaking on main.

Nothing tells how much the model leaves out around such a $ref, so when the walk
finds one and keeps the direction of a oneOf, it walks the document again with
every oneOf shared and uses all of that, as before the previous commit.

Co-Authored-By: Claude <noreply@anthropic.com>
…o dropped keywords

It still said every oneOf is shared again, which was true before the second walk
was limited to what the keywords the model drops reach.

Co-Authored-By: Claude <noreply@anthropic.com>
…eck in the usage walk

The second walk reaches the same schemas as the first, which already found the
document known, so its unknown check could never return. Cover the boolean type
of a oneOf branch, and move the doc comment of widgetUsage back onto it.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

what-changed: required property added to a response-only schema is reported as breaking when used inside oneOf

2 participants