docusaurus-theme-openapi-docs 0.0.0-1069 → 0.0.0-1073
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 +41 -0
- package/package.json +3 -3
- package/src/theme/Schema/index.tsx +42 -0
|
@@ -797,6 +797,47 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
797
797
|
}
|
|
798
798
|
// Handle allOf, oneOf, anyOf without discriminators
|
|
799
799
|
if (schema.allOf) {
|
|
800
|
+
// Check if allOf contains multiple oneOf/anyOf items that should be rendered separately
|
|
801
|
+
const oneOfItems = schema.allOf.filter((item) => item.oneOf || item.anyOf);
|
|
802
|
+
const hasMultipleChoices = oneOfItems.length > 1;
|
|
803
|
+
if (hasMultipleChoices) {
|
|
804
|
+
// Render each oneOf/anyOf constraint first, then shared properties
|
|
805
|
+
const mergedSchemas = mergeAllOf(schema);
|
|
806
|
+
if (
|
|
807
|
+
(schemaType === "request" && mergedSchemas.readOnly) ||
|
|
808
|
+
(schemaType === "response" && mergedSchemas.writeOnly)
|
|
809
|
+
) {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
return react_1.default.createElement(
|
|
813
|
+
"div",
|
|
814
|
+
null,
|
|
815
|
+
schema.allOf.map((item, index) => {
|
|
816
|
+
if (item.oneOf || item.anyOf) {
|
|
817
|
+
return react_1.default.createElement(
|
|
818
|
+
"div",
|
|
819
|
+
{ key: index },
|
|
820
|
+
react_1.default.createElement(AnyOneOf, {
|
|
821
|
+
schema: item,
|
|
822
|
+
schemaType: schemaType,
|
|
823
|
+
})
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
return null;
|
|
827
|
+
}),
|
|
828
|
+
mergedSchemas.properties &&
|
|
829
|
+
react_1.default.createElement(Properties, {
|
|
830
|
+
schema: mergedSchemas,
|
|
831
|
+
schemaType: schemaType,
|
|
832
|
+
}),
|
|
833
|
+
mergedSchemas.items &&
|
|
834
|
+
react_1.default.createElement(Items, {
|
|
835
|
+
schema: mergedSchemas,
|
|
836
|
+
schemaType: schemaType,
|
|
837
|
+
})
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
// For other allOf cases, use standard merge behavior
|
|
800
841
|
const mergedSchemas = mergeAllOf(schema);
|
|
801
842
|
if (
|
|
802
843
|
(schemaType === "request" && mergedSchemas.readOnly) ||
|
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-1073",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/postman-collection": "^3.5.11",
|
|
39
39
|
"@types/react-modal": "^3.16.3",
|
|
40
40
|
"concurrently": "^9.2.0",
|
|
41
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1073",
|
|
42
42
|
"docusaurus-plugin-sass": "^0.2.6",
|
|
43
43
|
"eslint-plugin-prettier": "^5.5.1"
|
|
44
44
|
},
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=14"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "d6c29401ee71e04536c4ece3054c414a79e750da"
|
|
85
85
|
}
|
|
@@ -885,6 +885,48 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
|
885
885
|
|
|
886
886
|
// Handle allOf, oneOf, anyOf without discriminators
|
|
887
887
|
if (schema.allOf) {
|
|
888
|
+
// Check if allOf contains multiple oneOf/anyOf items that should be rendered separately
|
|
889
|
+
const oneOfItems = schema.allOf.filter(
|
|
890
|
+
(item: any) => item.oneOf || item.anyOf
|
|
891
|
+
);
|
|
892
|
+
const hasMultipleChoices = oneOfItems.length > 1;
|
|
893
|
+
|
|
894
|
+
if (hasMultipleChoices) {
|
|
895
|
+
// Render each oneOf/anyOf constraint first, then shared properties
|
|
896
|
+
const mergedSchemas = mergeAllOf(schema) as SchemaObject;
|
|
897
|
+
|
|
898
|
+
if (
|
|
899
|
+
(schemaType === "request" && mergedSchemas.readOnly) ||
|
|
900
|
+
(schemaType === "response" && mergedSchemas.writeOnly)
|
|
901
|
+
) {
|
|
902
|
+
return null;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
return (
|
|
906
|
+
<div>
|
|
907
|
+
{/* Render all oneOf/anyOf constraints first */}
|
|
908
|
+
{schema.allOf.map((item: any, index: number) => {
|
|
909
|
+
if (item.oneOf || item.anyOf) {
|
|
910
|
+
return (
|
|
911
|
+
<div key={index}>
|
|
912
|
+
<AnyOneOf schema={item} schemaType={schemaType} />
|
|
913
|
+
</div>
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
return null;
|
|
917
|
+
})}
|
|
918
|
+
{/* Then render shared properties from the merge */}
|
|
919
|
+
{mergedSchemas.properties && (
|
|
920
|
+
<Properties schema={mergedSchemas} schemaType={schemaType} />
|
|
921
|
+
)}
|
|
922
|
+
{mergedSchemas.items && (
|
|
923
|
+
<Items schema={mergedSchemas} schemaType={schemaType} />
|
|
924
|
+
)}
|
|
925
|
+
</div>
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// For other allOf cases, use standard merge behavior
|
|
888
930
|
const mergedSchemas = mergeAllOf(schema) as SchemaObject;
|
|
889
931
|
|
|
890
932
|
if (
|