Skip to content

Commit 7a5535e

Browse files
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

3 files changed

+498
-7
lines changed

demo/examples/tests/allOf.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,39 @@ paths:
510510
name:
511511
type: string
512512

513+
/allof-empty-object-properties:
514+
get:
515+
tags:
516+
- allOf
517+
summary: allOf with explicit empty object properties
518+
description: |
519+
Demonstrates an intentional empty object schema (properties: {}) to ensure
520+
the renderer still shows the object shape rather than hiding it.
521+
522+
Schema:
523+
```yaml
524+
type: object
525+
properties:
526+
metadata:
527+
type: object
528+
properties: {}
529+
name:
530+
type: string
531+
```
532+
responses:
533+
"200":
534+
description: Successful response
535+
content:
536+
application/json:
537+
schema:
538+
type: object
539+
properties:
540+
metadata:
541+
type: object
542+
properties: {}
543+
name:
544+
type: string
545+
513546
/allof-multiple-oneof:
514547
post:
515548
tags:

0 commit comments

Comments
 (0)