bugfix: nested oneOf/anyOf inside allOf#1250
Merged
Conversation
- Detect when allOf contains multiple oneOf/anyOf items - Render each constraint separately instead of merging (which loses information) - Display oneOf/anyOf constraints before shared properties - Fixes issue where nested oneOf schemas were not properly rendered in security-rules schema
- Demonstrates allOf containing two independent oneOf groups - Shows realistic pattern where object must satisfy multiple constraints - Includes shared properties that apply to all combinations - Tests the fix for rendering multiple oneOf items within allOf
|
Size Change: +1.46 kB (+0.07%) Total Size: 2.14 MB
ℹ️ View Unchanged
|
|
Visit the preview URL for this PR (updated for commit 23ba905): https://docusaurus-openapi-36b86--pr1250-rwhd9r00.web.app (expires Sat, 20 Dec 2025 15:44:15 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bf293780ee827f578864d92193b8c2866acd459f |
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.
Description
Issue
When rendering OpenAPI schemas with
allOfcontaining multipleoneOforanyOfitems, the nested schemas were not rendering properly. The schema merge operation was losing or combining the separate constraint arrays instead of preserving them as independent options.Example Schema Pattern
This issue affected schemas like:
allOf:
Constraint 1: Must be one of these policy types
discriminator: ...
Constraint 2: Must exist in one of these scopes
oneOfgroup (multiple independent constraints), but only oneoneOfwas rendering or they were incorrectly merged together.Affected Operations
POST /security-rules) inexamples/httpbin.yamlallOfwith multipleoneOf/anyOfconstraintsRoot Cause
The
SchemaNodecomponent was usingmergeAllOf()for allallOfschemas, which flattens multipleoneOfarrays into a single merged result. This loses the independence of each constraint.Solution
Modified
packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx:allOfcontains more than oneoneOforanyOfitemoneOf/anyOfconstraint separately as its own tabbed interfaceallOfmerge behavior is preserved for schemas without multiple choice constraintsRendering Order
oneOf/anyOfconstraints (each as tabbed options)Changes
packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsxPOST /allof-multiple-oneofindemo/examples/tests/allOf.yamlTesting
The fix has been tested with:
httpbin.yamlallOf.yamldemonstrating:oneOfconstraints (type selection + scope selection)Screenshots
Before
Only one
oneOfwas visible, or constraints were incorrectly mergedAfter
Both
oneOfconstraints render as separate tabbed interfaces, followed by shared properties