Commit 7a5535e
fix(theme): handle nested discriminators in allOf structures (#1303)
* fix(theme): handle nested discriminators in allOf structures
Add support for discriminators nested within allOf schemas. Previously,
discriminators inside allOf items were not properly detected, and the
discriminator property lookup only checked top-level schema properties.
Changes:
- Add findProperty() helper to recursively search for properties in
nested oneOf/anyOf/allOf structures
- Update DiscriminatorNode to use findProperty() for discriminator
property lookup
- Update SchemaNode to check for discriminators in allOf items and
merge schemas before processing
- Return null instead of empty "object" SchemaItem when properties
are empty after discriminator processing
- Add test case for nested discriminator in allOf
This fixes scenarios like:
```yaml
allOf:
- $ref: CommonProps
- oneOf: [VariantA, VariantB]
discriminator:
propertyName: type
```
Fixes #1302
* fix(theme): improve nested discriminator handling and examples
Handle recursively nested discriminators in composed schemas while preserving intentional empty-object rendering, and add demo specs covering deep allOf discriminator chains and explicit empty object properties.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 6198c9b commit 7a5535e
File tree
3 files changed
+498
-7
lines changed- demo/examples/tests
- packages/docusaurus-theme-openapi-docs/src/theme/Schema
3 files changed
+498
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
513 | 546 | | |
514 | 547 | | |
515 | 548 | | |
| |||
0 commit comments