File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed
packages/docusaurus-theme-openapi-docs/src/theme/Schema Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,35 @@ paths:
321
321
application/json :
322
322
schema :
323
323
$ref : " #/components/schemas/BaseRequiredMapping"
324
+
325
+ /discriminator-empty-subschema :
326
+ get :
327
+ tags :
328
+ - discriminator
329
+ summary : Discriminator with Subschema Inheriting All Fields (No Extra Fields)
330
+ description : |
331
+ This schema reproduces a sub-schema that inherits all fields from the parent (via allOf) and does not define any new properties.
332
+ Schema:
333
+ ```yaml
334
+ type: object
335
+ discriminator:
336
+ propertyName: type
337
+ mapping:
338
+ EmptyType: '#/components/schemas/EmptyType'
339
+ properties:
340
+ type:
341
+ type: string
342
+ oneOf:
343
+ - $ref: '#/components/schemas/EmptyType'
344
+ ```
345
+ responses :
346
+ " 200 " :
347
+ description : Successful response
348
+ content :
349
+ application/json :
350
+ schema :
351
+ $ref : " #/components/schemas/BaseEmptySubschema"
352
+
324
353
components :
325
354
schemas :
326
355
BaseBasic :
@@ -470,6 +499,18 @@ components:
470
499
- $ref : " #/components/schemas/TypeA"
471
500
- $ref : " #/components/schemas/TypeB"
472
501
502
+ BaseEmptySubschema :
503
+ type : object
504
+ discriminator :
505
+ propertyName : type
506
+ mapping :
507
+ EmptyType : " #/components/schemas/EmptyType"
508
+ properties :
509
+ type :
510
+ type : string
511
+ oneOf :
512
+ - $ref : " #/components/schemas/EmptyType"
513
+
473
514
TypeA :
474
515
type : object
475
516
properties :
@@ -523,3 +564,8 @@ components:
523
564
type : boolean
524
565
required :
525
566
- type
567
+
568
+ EmptyType :
569
+ type : object
570
+ allOf :
571
+ - $ref : " #/components/schemas/BaseEmptySubschema"
Original file line number Diff line number Diff line change @@ -352,7 +352,8 @@ const DiscriminatorNode: React.FC<DiscriminatorNodeProps> = ({
352
352
}
353
353
354
354
const subProperties = subSchema . properties || mergedSubSchema . properties ;
355
- if ( subProperties [ discriminator . propertyName ] ) {
355
+ // Add a safeguard check to avoid referencing subProperties if it's undefined
356
+ if ( subProperties && subProperties [ discriminator . propertyName ] ) {
356
357
if ( schema . properties ) {
357
358
schema . properties ! [ discriminator . propertyName ] = {
358
359
...schema . properties ! [ discriminator . propertyName ] ,
You can’t perform that action at this time.
0 commit comments