docusaurus-theme-openapi-docs 0.0.0-1006 → 0.0.0-1008
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 +27 -93
- package/package.json +3 -3
- package/src/theme/Schema/index.tsx +27 -73
|
@@ -481,111 +481,45 @@ const SchemaNodeDetails = ({
|
|
|
481
481
|
);
|
|
482
482
|
};
|
|
483
483
|
const Items = ({ schema, schemaType }) => {
|
|
484
|
-
//
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
null,
|
|
489
|
-
react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
|
|
490
|
-
react_1.default.createElement(Properties, {
|
|
491
|
-
schema: schema.items,
|
|
492
|
-
schemaType: schemaType,
|
|
493
|
-
}),
|
|
494
|
-
react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
|
|
495
|
-
);
|
|
496
|
-
}
|
|
497
|
-
// Handles case when schema.items has additionalProperties
|
|
498
|
-
if (schema.items?.additionalProperties) {
|
|
499
|
-
return react_1.default.createElement(
|
|
500
|
-
react_1.default.Fragment,
|
|
501
|
-
null,
|
|
502
|
-
react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
|
|
503
|
-
react_1.default.createElement(AdditionalProperties, {
|
|
504
|
-
schema: schema.items,
|
|
505
|
-
schemaType: schemaType,
|
|
506
|
-
}),
|
|
507
|
-
react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
|
|
508
|
-
);
|
|
484
|
+
// Process schema.items to handle allOf merging
|
|
485
|
+
let itemsSchema = schema.items;
|
|
486
|
+
if (schema.items?.allOf) {
|
|
487
|
+
itemsSchema = mergeAllOf(schema.items);
|
|
509
488
|
}
|
|
510
|
-
//
|
|
511
|
-
|
|
489
|
+
// Handle complex schemas with multiple schema types
|
|
490
|
+
const hasOneOfAnyOf = itemsSchema?.oneOf || itemsSchema?.anyOf;
|
|
491
|
+
const hasProperties = itemsSchema?.properties;
|
|
492
|
+
const hasAdditionalProperties = itemsSchema?.additionalProperties;
|
|
493
|
+
if (hasOneOfAnyOf || hasProperties || hasAdditionalProperties) {
|
|
512
494
|
return react_1.default.createElement(
|
|
513
495
|
react_1.default.Fragment,
|
|
514
496
|
null,
|
|
515
497
|
react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
|
|
516
|
-
|
|
517
|
-
schema: schema.items,
|
|
518
|
-
schemaType: schemaType,
|
|
519
|
-
}),
|
|
520
|
-
react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
// Handles case when schema.items has allOf
|
|
524
|
-
if (schema.items?.allOf) {
|
|
525
|
-
const mergedSchemas = mergeAllOf(schema.items);
|
|
526
|
-
// Handles combo anyOf/oneOf + properties
|
|
527
|
-
if (
|
|
528
|
-
(mergedSchemas.oneOf || mergedSchemas.anyOf) &&
|
|
529
|
-
mergedSchemas.properties
|
|
530
|
-
) {
|
|
531
|
-
return react_1.default.createElement(
|
|
532
|
-
react_1.default.Fragment,
|
|
533
|
-
null,
|
|
534
|
-
react_1.default.createElement(
|
|
535
|
-
ArrayBrackets_1.OpeningArrayBracket,
|
|
536
|
-
null
|
|
537
|
-
),
|
|
498
|
+
hasOneOfAnyOf &&
|
|
538
499
|
react_1.default.createElement(AnyOneOf, {
|
|
539
|
-
schema:
|
|
500
|
+
schema: itemsSchema,
|
|
540
501
|
schemaType: schemaType,
|
|
541
502
|
}),
|
|
503
|
+
hasProperties &&
|
|
542
504
|
react_1.default.createElement(Properties, {
|
|
543
|
-
schema:
|
|
544
|
-
schemaType: schemaType,
|
|
545
|
-
}),
|
|
546
|
-
react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
|
|
547
|
-
);
|
|
548
|
-
}
|
|
549
|
-
// Handles only anyOf/oneOf
|
|
550
|
-
if (mergedSchemas.oneOf || mergedSchemas.anyOf) {
|
|
551
|
-
return react_1.default.createElement(
|
|
552
|
-
react_1.default.Fragment,
|
|
553
|
-
null,
|
|
554
|
-
react_1.default.createElement(
|
|
555
|
-
ArrayBrackets_1.OpeningArrayBracket,
|
|
556
|
-
null
|
|
557
|
-
),
|
|
558
|
-
react_1.default.createElement(AnyOneOf, {
|
|
559
|
-
schema: mergedSchemas,
|
|
505
|
+
schema: itemsSchema,
|
|
560
506
|
schemaType: schemaType,
|
|
561
507
|
}),
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
// Handles properties
|
|
566
|
-
if (mergedSchemas.properties) {
|
|
567
|
-
return react_1.default.createElement(
|
|
568
|
-
react_1.default.Fragment,
|
|
569
|
-
null,
|
|
570
|
-
react_1.default.createElement(
|
|
571
|
-
ArrayBrackets_1.OpeningArrayBracket,
|
|
572
|
-
null
|
|
573
|
-
),
|
|
574
|
-
react_1.default.createElement(Properties, {
|
|
575
|
-
schema: mergedSchemas,
|
|
508
|
+
hasAdditionalProperties &&
|
|
509
|
+
react_1.default.createElement(AdditionalProperties, {
|
|
510
|
+
schema: itemsSchema,
|
|
576
511
|
schemaType: schemaType,
|
|
577
512
|
}),
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
513
|
+
react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
|
|
514
|
+
);
|
|
581
515
|
}
|
|
582
516
|
// Handles basic types (string, number, integer, boolean, object)
|
|
583
517
|
if (
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
518
|
+
itemsSchema?.type === "string" ||
|
|
519
|
+
itemsSchema?.type === "number" ||
|
|
520
|
+
itemsSchema?.type === "integer" ||
|
|
521
|
+
itemsSchema?.type === "boolean" ||
|
|
522
|
+
itemsSchema?.type === "object"
|
|
589
523
|
) {
|
|
590
524
|
return react_1.default.createElement(
|
|
591
525
|
"div",
|
|
@@ -594,9 +528,9 @@ const Items = ({ schema, schemaType }) => {
|
|
|
594
528
|
react_1.default.createElement(SchemaItem_1.default, {
|
|
595
529
|
collapsible: false,
|
|
596
530
|
name: "", // No name for array items
|
|
597
|
-
schemaName: (0, schema_1.getSchemaName)(
|
|
598
|
-
qualifierMessage: (0, schema_1.getQualifierMessage)(
|
|
599
|
-
schema:
|
|
531
|
+
schemaName: (0, schema_1.getSchemaName)(itemsSchema),
|
|
532
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(itemsSchema),
|
|
533
|
+
schema: itemsSchema,
|
|
600
534
|
discriminator: false,
|
|
601
535
|
children: null,
|
|
602
536
|
}),
|
|
@@ -608,7 +542,7 @@ const Items = ({ schema, schemaType }) => {
|
|
|
608
542
|
react_1.default.Fragment,
|
|
609
543
|
null,
|
|
610
544
|
react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
|
|
611
|
-
Object.entries(
|
|
545
|
+
Object.entries(itemsSchema || {}).map(([key, val]) =>
|
|
612
546
|
react_1.default.createElement(SchemaEdge, {
|
|
613
547
|
key: key,
|
|
614
548
|
name: key,
|
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-1008",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/lodash": "^4.14.176",
|
|
37
37
|
"@types/pako": "^2.0.3",
|
|
38
38
|
"concurrently": "^5.2.0",
|
|
39
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
39
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1008",
|
|
40
40
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
41
41
|
"eslint-plugin-prettier": "^5.0.1"
|
|
42
42
|
},
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=14"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "d50a1409c5b6097064616bac66c5a079431c61de"
|
|
83
83
|
}
|
|
@@ -504,88 +504,42 @@ const Items: React.FC<{
|
|
|
504
504
|
schema: any;
|
|
505
505
|
schemaType: "request" | "response";
|
|
506
506
|
}> = ({ schema, schemaType }) => {
|
|
507
|
-
//
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
<OpeningArrayBracket />
|
|
512
|
-
<Properties schema={schema.items} schemaType={schemaType} />
|
|
513
|
-
<ClosingArrayBracket />
|
|
514
|
-
</>
|
|
515
|
-
);
|
|
507
|
+
// Process schema.items to handle allOf merging
|
|
508
|
+
let itemsSchema = schema.items;
|
|
509
|
+
if (schema.items?.allOf) {
|
|
510
|
+
itemsSchema = mergeAllOf(schema.items) as SchemaObject;
|
|
516
511
|
}
|
|
517
512
|
|
|
518
|
-
//
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
<OpeningArrayBracket />
|
|
523
|
-
<AdditionalProperties schema={schema.items} schemaType={schemaType} />
|
|
524
|
-
<ClosingArrayBracket />
|
|
525
|
-
</>
|
|
526
|
-
);
|
|
527
|
-
}
|
|
513
|
+
// Handle complex schemas with multiple schema types
|
|
514
|
+
const hasOneOfAnyOf = itemsSchema?.oneOf || itemsSchema?.anyOf;
|
|
515
|
+
const hasProperties = itemsSchema?.properties;
|
|
516
|
+
const hasAdditionalProperties = itemsSchema?.additionalProperties;
|
|
528
517
|
|
|
529
|
-
|
|
530
|
-
if (schema.items?.oneOf || schema.items?.anyOf) {
|
|
518
|
+
if (hasOneOfAnyOf || hasProperties || hasAdditionalProperties) {
|
|
531
519
|
return (
|
|
532
520
|
<>
|
|
533
521
|
<OpeningArrayBracket />
|
|
534
|
-
|
|
522
|
+
{hasOneOfAnyOf && (
|
|
523
|
+
<AnyOneOf schema={itemsSchema} schemaType={schemaType} />
|
|
524
|
+
)}
|
|
525
|
+
{hasProperties && (
|
|
526
|
+
<Properties schema={itemsSchema} schemaType={schemaType} />
|
|
527
|
+
)}
|
|
528
|
+
{hasAdditionalProperties && (
|
|
529
|
+
<AdditionalProperties schema={itemsSchema} schemaType={schemaType} />
|
|
530
|
+
)}
|
|
535
531
|
<ClosingArrayBracket />
|
|
536
532
|
</>
|
|
537
533
|
);
|
|
538
534
|
}
|
|
539
535
|
|
|
540
|
-
// Handles case when schema.items has allOf
|
|
541
|
-
if (schema.items?.allOf) {
|
|
542
|
-
const mergedSchemas = mergeAllOf(schema.items) as SchemaObject;
|
|
543
|
-
|
|
544
|
-
// Handles combo anyOf/oneOf + properties
|
|
545
|
-
if (
|
|
546
|
-
(mergedSchemas.oneOf || mergedSchemas.anyOf) &&
|
|
547
|
-
mergedSchemas.properties
|
|
548
|
-
) {
|
|
549
|
-
return (
|
|
550
|
-
<>
|
|
551
|
-
<OpeningArrayBracket />
|
|
552
|
-
<AnyOneOf schema={mergedSchemas} schemaType={schemaType} />
|
|
553
|
-
<Properties schema={mergedSchemas} schemaType={schemaType} />
|
|
554
|
-
<ClosingArrayBracket />
|
|
555
|
-
</>
|
|
556
|
-
);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
// Handles only anyOf/oneOf
|
|
560
|
-
if (mergedSchemas.oneOf || mergedSchemas.anyOf) {
|
|
561
|
-
return (
|
|
562
|
-
<>
|
|
563
|
-
<OpeningArrayBracket />
|
|
564
|
-
<AnyOneOf schema={mergedSchemas} schemaType={schemaType} />
|
|
565
|
-
<ClosingArrayBracket />
|
|
566
|
-
</>
|
|
567
|
-
);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// Handles properties
|
|
571
|
-
if (mergedSchemas.properties) {
|
|
572
|
-
return (
|
|
573
|
-
<>
|
|
574
|
-
<OpeningArrayBracket />
|
|
575
|
-
<Properties schema={mergedSchemas} schemaType={schemaType} />
|
|
576
|
-
<ClosingArrayBracket />
|
|
577
|
-
</>
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
536
|
// Handles basic types (string, number, integer, boolean, object)
|
|
583
537
|
if (
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
538
|
+
itemsSchema?.type === "string" ||
|
|
539
|
+
itemsSchema?.type === "number" ||
|
|
540
|
+
itemsSchema?.type === "integer" ||
|
|
541
|
+
itemsSchema?.type === "boolean" ||
|
|
542
|
+
itemsSchema?.type === "object"
|
|
589
543
|
) {
|
|
590
544
|
return (
|
|
591
545
|
<div style={{ marginLeft: ".5rem" }}>
|
|
@@ -593,9 +547,9 @@ const Items: React.FC<{
|
|
|
593
547
|
<SchemaItem
|
|
594
548
|
collapsible={false}
|
|
595
549
|
name="" // No name for array items
|
|
596
|
-
schemaName={getSchemaName(
|
|
597
|
-
qualifierMessage={getQualifierMessage(
|
|
598
|
-
schema={
|
|
550
|
+
schemaName={getSchemaName(itemsSchema)}
|
|
551
|
+
qualifierMessage={getQualifierMessage(itemsSchema)}
|
|
552
|
+
schema={itemsSchema}
|
|
599
553
|
discriminator={false}
|
|
600
554
|
children={null}
|
|
601
555
|
/>
|
|
@@ -608,7 +562,7 @@ const Items: React.FC<{
|
|
|
608
562
|
return (
|
|
609
563
|
<>
|
|
610
564
|
<OpeningArrayBracket />
|
|
611
|
-
{Object.entries(
|
|
565
|
+
{Object.entries(itemsSchema || {}).map(([key, val]: [string, any]) => (
|
|
612
566
|
<SchemaEdge
|
|
613
567
|
key={key}
|
|
614
568
|
name={key}
|