Do not mistake a grouping node for a schema because of a child's name - #47
Merged
Merged
Conversation
CollectDefinitions told a grouping node apart from a schema by the names of its child keys, but specification node names share a namespace with JSON Schema keywords. The booleanOperations group holds and/or/not, and the single "not" key was enough to take the whole group for a schema: its three members were never emitted, and the refs to booleanOperations_and/_or/_not from booleanReturning were left dangling. A node is now checked first for children that are targets of "#/definitions/..." pointers; such a node is always a group. The keyword heuristic stays as the fallback. Components.Schemas is initialised along the way as well: on a document without a single generated schema the transformer threw a NullReferenceException, which made it impossible to call directly from a test. Closes #46 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
kudima03
force-pushed
the
fix/boolean-operations-dangling-refs
branch
from
August 21, 2026 14:33
48d2e1f to
e751a7f
Compare
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.
Closes #46
Cause
CollectDefinitionstold a grouping node apart from a schema node by the names of the child keys:Specification node names share a namespace with JSON Schema keywords. The
booleanOperationsgroup holdsor,andandnot— and the singlenotkey was enough forAny(...)to returntrueand for the whole group to be taken for a schema. No recursion happened, so its three members were never emitted.Beyond the dangling refs this also produced a semantically wrong component:
booleanOperationslanded in the document as a schema,Microsoft.OpenApitook thenotkey for the keyword of the same name, andandandorended up inunrecognizedKeywords.What changed
A node is now checked first for children that are targets of
#/definitions/...pointers. Such a node is always a group, no matter what its children are called. The keyword check stays as the fallback for nodes whose members nothing references.The set of targets is collected by the new
CollectDefinitionPointers, which walks the specification once before the main pass.Components.Schemasis initialised separately:document.Components ??= new OpenApiComponents()already stood next to it, but on a document without a single generated schemaSchemasstayednulland the transformer threw aNullReferenceException— which is what made it impossible to call directly from a test.Result on the real specification
booleanOperationsas a schemabooleanOperations_and/_or/_notNothing else moved: no existing schema disappeared or changed its contents — exactly three missing ones were added and exactly one wrong component was removed.
Tests
The test project held only
FakeTest, so these are the first real tests, written against a minimal specification that reproduces the name collision:EmitsMembersOfGroupNamedLikeSchemaKeyword(aTheoryover the three members of the group)DoesNotEmitGroupingNodeAsSchemaLeavesNoDanglingComponentReferences— serialises the document and checks that every$refresolvesVerified that the tests are not vacuous: with the fix reverted all five fail, with the fix all six pass. Every CI step was run locally —
dotnet build -warnaserror,dotnet format --verify-no-changes,csharpier check .,dotnet test.🤖 Generated with Claude Code