feat: expose open string enum branches - #5
Merged
Conversation
An anyOf can combine a string enum with an enum-free string branch to document common values without closing the accepted set. Consumers currently have to repeat that structural interpretation themselves.\n\nExpose the enum-bearing branch from CompositeSchema when the union has exactly that shape. Keep oneOf, mixed-type unions, and unions with multiple enums unchanged.
Greptile SummaryThe PR adds a narrowly scoped semantic query for retrieving the enum-bearing branch from an open string
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The helper enforces the documented Important Files Changed
Reviews (1): Last reviewed commit: "feat: expose open string enum branches" | Re-trigger Greptile |
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.
What
Expose the enum-bearing branch when an
anyOfcombines exactly one string enum with one or more enum-free string branches.This shape documents the values callers commonly use without closing the accepted string set:
{ "anyOf": [ { "type": "string", "enum": ["network.requests", "network.inbound"] }, { "type": "string" } ] }Consumers can now use the canonical model directly:
instead of duplicating composition and branch inspection.
Behavior
The query is deliberately narrow and returns
nullunless:anyOf;StringSchema;Branch order does not matter.
oneOf,allOf, mixed-type unions, closed enums, and unions containing multiple enums remain unchanged.Context
This semantic query is needed by appwrite/sdk-generator#1816. Keeping it in the canonical OpenAPI model prevents individual generators from maintaining their own schema-shape parsers and lets them focus on language-specific rendering.
Test plan
oneOfandallOfare rejected;composer checkpasses: 48 tests, 382 assertions.