docusaurus-theme-openapi-docs 0.0.0-958 → 0.0.0-960
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/theme/Schema/index.js +20 -9
- package/package.json +3 -3
- package/src/theme/Schema/index.tsx +20 -10
|
@@ -316,7 +316,10 @@ const PropertyDiscriminator = ({
|
|
|
316
316
|
const DiscriminatorNode = ({ discriminator, schema, schemaType }) => {
|
|
317
317
|
let discriminatedSchemas = {};
|
|
318
318
|
let inferredMapping = {};
|
|
319
|
-
|
|
319
|
+
// default to empty object if no parent-level properties exist
|
|
320
|
+
const discriminatorProperty = schema.properties
|
|
321
|
+
? schema.properties[discriminator.propertyName]
|
|
322
|
+
: {};
|
|
320
323
|
if (schema.allOf) {
|
|
321
324
|
const mergedSchemas = mergeAllOf(schema);
|
|
322
325
|
if (mergedSchemas.oneOf || mergedSchemas.anyOf) {
|
|
@@ -342,15 +345,23 @@ const DiscriminatorNode = ({ discriminator, schema, schemaType }) => {
|
|
|
342
345
|
}
|
|
343
346
|
const subProperties = subSchema.properties || mergedSubSchema.properties;
|
|
344
347
|
if (subProperties[discriminator.propertyName]) {
|
|
345
|
-
schema.properties
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
if (schema.properties) {
|
|
349
|
+
schema.properties[discriminator.propertyName] = {
|
|
350
|
+
...schema.properties[discriminator.propertyName],
|
|
351
|
+
...subProperties[discriminator.propertyName],
|
|
352
|
+
};
|
|
353
|
+
if (subSchema.required && !schema.required) {
|
|
354
|
+
schema.required = subSchema.required;
|
|
355
|
+
}
|
|
356
|
+
// Avoid duplicating property
|
|
357
|
+
delete subProperties[discriminator.propertyName];
|
|
358
|
+
} else {
|
|
359
|
+
schema.properties = {};
|
|
360
|
+
schema.properties[discriminator.propertyName] =
|
|
361
|
+
subProperties[discriminator.propertyName];
|
|
362
|
+
// Avoid duplicating property
|
|
363
|
+
delete subProperties[discriminator.propertyName];
|
|
351
364
|
}
|
|
352
|
-
// Avoid duplicating property
|
|
353
|
-
delete subProperties[discriminator.propertyName];
|
|
354
365
|
}
|
|
355
366
|
});
|
|
356
367
|
const name = discriminator.propertyName;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-960",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@types/file-saver": "^2.0.5",
|
|
35
35
|
"@types/lodash": "^4.14.176",
|
|
36
36
|
"concurrently": "^5.2.0",
|
|
37
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
37
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-960",
|
|
38
38
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
39
39
|
"eslint-plugin-prettier": "^5.0.1"
|
|
40
40
|
},
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=14"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "567fb462ff9cdc7a54be3a37b00c94e93deda61c"
|
|
79
79
|
}
|
|
@@ -317,7 +317,10 @@ const DiscriminatorNode: React.FC<DiscriminatorNodeProps> = ({
|
|
|
317
317
|
let discriminatedSchemas: any = {};
|
|
318
318
|
let inferredMapping: any = {};
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
// default to empty object if no parent-level properties exist
|
|
321
|
+
const discriminatorProperty = schema.properties
|
|
322
|
+
? schema.properties![discriminator.propertyName]
|
|
323
|
+
: {};
|
|
321
324
|
|
|
322
325
|
if (schema.allOf) {
|
|
323
326
|
const mergedSchemas = mergeAllOf(schema) as SchemaObject;
|
|
@@ -350,21 +353,28 @@ const DiscriminatorNode: React.FC<DiscriminatorNodeProps> = ({
|
|
|
350
353
|
|
|
351
354
|
const subProperties = subSchema.properties || mergedSubSchema.properties;
|
|
352
355
|
if (subProperties[discriminator.propertyName]) {
|
|
353
|
-
schema.properties
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
if (schema.properties) {
|
|
357
|
+
schema.properties![discriminator.propertyName] = {
|
|
358
|
+
...schema.properties![discriminator.propertyName],
|
|
359
|
+
...subProperties[discriminator.propertyName],
|
|
360
|
+
};
|
|
361
|
+
if (subSchema.required && !schema.required) {
|
|
362
|
+
schema.required = subSchema.required;
|
|
363
|
+
}
|
|
364
|
+
// Avoid duplicating property
|
|
365
|
+
delete subProperties[discriminator.propertyName];
|
|
366
|
+
} else {
|
|
367
|
+
schema.properties = {};
|
|
368
|
+
schema.properties[discriminator.propertyName] =
|
|
369
|
+
subProperties[discriminator.propertyName];
|
|
370
|
+
// Avoid duplicating property
|
|
371
|
+
delete subProperties[discriminator.propertyName];
|
|
359
372
|
}
|
|
360
|
-
// Avoid duplicating property
|
|
361
|
-
delete subProperties[discriminator.propertyName];
|
|
362
373
|
}
|
|
363
374
|
});
|
|
364
375
|
|
|
365
376
|
const name = discriminator.propertyName;
|
|
366
377
|
const schemaName = getSchemaName(discriminatorProperty);
|
|
367
|
-
|
|
368
378
|
// Default case for discriminator without oneOf/anyOf/allOf
|
|
369
379
|
return (
|
|
370
380
|
<PropertyDiscriminator
|