fix(jsonschema): preserve scalar unions nested in a single-branch anyOf wrapper #3
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
go
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nemith/nvueschema!3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/anyof-scalar-union-collapse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
A property written as
{"anyOf":[{"$ref":X}],"nullable":true}— the OpenAPI idiom for attachingnullable/description to a$ref— is a passthrough, not a union.When
Xis itself a scalar union (e.g. the aclmatch/ip/protocoldef:integer(0-255) | string enum (tcp,udp,icmp,...)),isScalarUnionsees the wrapper's single non-scalar branch and falls through toFlattenComposite, which mergesanyOf/oneOfbranches with first-Type-wins and never copiesEnum— collapsing the union to a lone integer.The generated schema then rejects valid values like
protocol: tcpwithgot string, want null or integer. This affects effectively every ACL rule across all Cumulus versions.Fix
scalarUnionVariants: surface the inner union's variants through a single-branchanyOf/oneOfwrapper, so the union is preserved rather than collapsed.scalarUnionToJSONSchema: carry each branch's scalar constraints (minimum/maximum,minLength/maxLength,pattern) so e.g. the integer branch keeps its 0-255 bounds.Test
TestScalarUnion_NestedInSingleBranchWrapper_Preservedreproduces the exactprotocolshape and asserts the output is ananyOfretaining both the integer(0-255) and string-enum(tcp,...) branches rather than collapsing to a scalar.🤖 Generated with Claude Code