docusaurus-plugin-openapi-docs 2.1.1 → 2.1.3
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/markdown/createSchema.d.ts +1 -1
- package/lib/markdown/createSchema.js +23 -9
- package/lib/markdown/schema.js +3 -0
- package/lib/sidebars/index.js +1 -1
- package/package.json +2 -2
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +4 -28
- package/src/markdown/createSchema.ts +31 -18
- package/src/markdown/schema.ts +4 -0
- package/src/sidebars/index.ts +1 -1
|
@@ -4,7 +4,7 @@ import { SchemaObject } from "../openapi/types";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function mergeAllOf(allOf: SchemaObject[]): {
|
|
6
6
|
mergedSchemas: any;
|
|
7
|
-
|
|
7
|
+
mergedRequired: any;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
|
|
@@ -40,14 +40,14 @@ function mergeAllOf(allOf) {
|
|
|
40
40
|
},
|
|
41
41
|
ignoreAdditionalProperties: true,
|
|
42
42
|
});
|
|
43
|
-
const
|
|
43
|
+
const mergedRequired = allOf.reduce((acc, cur) => {
|
|
44
44
|
if (Array.isArray(cur.required)) {
|
|
45
45
|
const next = [...acc, ...cur.required];
|
|
46
46
|
return next;
|
|
47
47
|
}
|
|
48
48
|
return acc;
|
|
49
49
|
}, []);
|
|
50
|
-
return { mergedSchemas,
|
|
50
|
+
return { mergedSchemas, mergedRequired };
|
|
51
51
|
}
|
|
52
52
|
exports.mergeAllOf = mergeAllOf;
|
|
53
53
|
/**
|
|
@@ -491,7 +491,7 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
491
491
|
return createAnyOneOfProperty(name, schemaName, schema, required, schema.nullable);
|
|
492
492
|
}
|
|
493
493
|
if (schema.allOf !== undefined) {
|
|
494
|
-
const { mergedSchemas
|
|
494
|
+
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
495
495
|
const mergedSchemaName = (0, schema_1.getSchemaName)(mergedSchemas);
|
|
496
496
|
if (mergedSchemas.oneOf !== undefined ||
|
|
497
497
|
mergedSchemas.anyOf !== undefined) {
|
|
@@ -521,8 +521,8 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
521
521
|
collapsible: false,
|
|
522
522
|
name,
|
|
523
523
|
required: Array.isArray(required) ? required.includes(name) : required,
|
|
524
|
-
schemaName:
|
|
525
|
-
qualifierMessage: (0, schema_1.getQualifierMessage)(
|
|
524
|
+
schemaName: mergedSchemaName,
|
|
525
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(mergedSchemas),
|
|
526
526
|
schema: mergedSchemas,
|
|
527
527
|
});
|
|
528
528
|
}
|
|
@@ -610,9 +610,16 @@ function createNodes(schema, schemaType) {
|
|
|
610
610
|
style: {
|
|
611
611
|
marginTop: ".5rem",
|
|
612
612
|
marginBottom: ".5rem",
|
|
613
|
-
marginLeft: "1rem",
|
|
614
613
|
},
|
|
615
|
-
children:
|
|
614
|
+
children: [
|
|
615
|
+
(0, createDescription_1.createDescription)(schema.type),
|
|
616
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
617
|
+
style: {
|
|
618
|
+
paddingTop: "1rem",
|
|
619
|
+
},
|
|
620
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
621
|
+
})),
|
|
622
|
+
],
|
|
616
623
|
});
|
|
617
624
|
}
|
|
618
625
|
// handle circular references
|
|
@@ -621,9 +628,16 @@ function createNodes(schema, schemaType) {
|
|
|
621
628
|
style: {
|
|
622
629
|
marginTop: ".5rem",
|
|
623
630
|
marginBottom: ".5rem",
|
|
624
|
-
marginLeft: "1rem",
|
|
625
631
|
},
|
|
626
|
-
children: [
|
|
632
|
+
children: [
|
|
633
|
+
(0, createDescription_1.createDescription)(schema),
|
|
634
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
635
|
+
style: {
|
|
636
|
+
paddingTop: "1rem",
|
|
637
|
+
},
|
|
638
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
639
|
+
})),
|
|
640
|
+
],
|
|
627
641
|
});
|
|
628
642
|
}
|
|
629
643
|
// Unknown node/schema type should return undefined
|
package/lib/markdown/schema.js
CHANGED
|
@@ -35,6 +35,9 @@ function prettyName(schema, circular) {
|
|
|
35
35
|
return (_d = (_c = schema.xml) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : schema.type;
|
|
36
36
|
// return schema.type;
|
|
37
37
|
}
|
|
38
|
+
if (schema.title && schema.type) {
|
|
39
|
+
return `${schema.title} (${schema.type})`;
|
|
40
|
+
}
|
|
38
41
|
return (_e = schema.title) !== null && _e !== void 0 ? _e : schema.type;
|
|
39
42
|
}
|
|
40
43
|
function getSchemaName(schema, circular) {
|
package/lib/sidebars/index.js
CHANGED
|
@@ -52,7 +52,7 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
52
52
|
apiTags.push(tag.name);
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
apiTags = (0, uniq_1.default)(apiTags.concat(operationTags));
|
|
56
56
|
const basePath = docPath
|
|
57
57
|
? outputDir.split(docPath)[1].replace(/^\/+/g, "")
|
|
58
58
|
: outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=14"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3bca23ffd3bc51c3d7f4ebb3916e2ece8c823961"
|
|
64
64
|
}
|
|
@@ -35,13 +35,7 @@ Array [
|
|
|
35
35
|
Array [
|
|
36
36
|
</div>
|
|
37
37
|
</li>
|
|
38
|
-
<div
|
|
39
|
-
style={{
|
|
40
|
-
marginTop: \\".5rem\\",
|
|
41
|
-
marginBottom: \\".5rem\\",
|
|
42
|
-
marginLeft: \\"1rem\\",
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
38
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
45
39
|
string
|
|
46
40
|
</div>
|
|
47
41
|
<li>
|
|
@@ -57,35 +51,17 @@ Array [
|
|
|
57
51
|
</li>
|
|
58
52
|
</TabItem>
|
|
59
53
|
<TabItem label={\\"MOD3\\"} value={\\"2-item-properties\\"}>
|
|
60
|
-
<div
|
|
61
|
-
style={{
|
|
62
|
-
marginTop: \\".5rem\\",
|
|
63
|
-
marginBottom: \\".5rem\\",
|
|
64
|
-
marginLeft: \\"1rem\\",
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
54
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
67
55
|
boolean
|
|
68
56
|
</div>
|
|
69
57
|
</TabItem>
|
|
70
58
|
<TabItem label={\\"MOD4\\"} value={\\"3-item-properties\\"}>
|
|
71
|
-
<div
|
|
72
|
-
style={{
|
|
73
|
-
marginTop: \\".5rem\\",
|
|
74
|
-
marginBottom: \\".5rem\\",
|
|
75
|
-
marginLeft: \\"1rem\\",
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
59
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
78
60
|
number
|
|
79
61
|
</div>
|
|
80
62
|
</TabItem>
|
|
81
63
|
<TabItem label={\\"MOD5\\"} value={\\"4-item-properties\\"}>
|
|
82
|
-
<div
|
|
83
|
-
style={{
|
|
84
|
-
marginTop: \\".5rem\\",
|
|
85
|
-
marginBottom: \\".5rem\\",
|
|
86
|
-
marginLeft: \\"1rem\\",
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
64
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
89
65
|
string
|
|
90
66
|
</div>
|
|
91
67
|
</TabItem>
|
|
@@ -44,7 +44,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
44
44
|
ignoreAdditionalProperties: true,
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
const
|
|
47
|
+
const mergedRequired = allOf.reduce((acc, cur) => {
|
|
48
48
|
if (Array.isArray(cur.required)) {
|
|
49
49
|
const next = [...acc, ...cur.required];
|
|
50
50
|
return next;
|
|
@@ -52,7 +52,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
52
52
|
return acc;
|
|
53
53
|
}, [] as any);
|
|
54
54
|
|
|
55
|
-
return { mergedSchemas,
|
|
55
|
+
return { mergedSchemas, mergedRequired };
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -260,9 +260,8 @@ function createItems(schema: SchemaObject) {
|
|
|
260
260
|
// TODO: figure out if and how we should pass merged required array
|
|
261
261
|
const {
|
|
262
262
|
mergedSchemas,
|
|
263
|
-
}: { mergedSchemas: SchemaObject;
|
|
264
|
-
schema.items?.allOf
|
|
265
|
-
);
|
|
263
|
+
}: { mergedSchemas: SchemaObject; mergedRequired: string[] | boolean } =
|
|
264
|
+
mergeAllOf(schema.items?.allOf);
|
|
266
265
|
|
|
267
266
|
// Handles combo anyOf/oneOf + properties
|
|
268
267
|
if (
|
|
@@ -596,7 +595,6 @@ function createEdges({
|
|
|
596
595
|
discriminator,
|
|
597
596
|
}: EdgeProps): any {
|
|
598
597
|
const schemaName = getSchemaName(schema);
|
|
599
|
-
|
|
600
598
|
if (discriminator !== undefined && discriminator.propertyName === name) {
|
|
601
599
|
return createPropertyDiscriminator(
|
|
602
600
|
name,
|
|
@@ -618,13 +616,10 @@ function createEdges({
|
|
|
618
616
|
}
|
|
619
617
|
|
|
620
618
|
if (schema.allOf !== undefined) {
|
|
621
|
-
const {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
}: { mergedSchemas: SchemaObject; required: string[] | boolean } =
|
|
625
|
-
mergeAllOf(schema.allOf);
|
|
619
|
+
const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
|
|
620
|
+
schema.allOf
|
|
621
|
+
);
|
|
626
622
|
const mergedSchemaName = getSchemaName(mergedSchemas);
|
|
627
|
-
|
|
628
623
|
if (
|
|
629
624
|
mergedSchemas.oneOf !== undefined ||
|
|
630
625
|
mergedSchemas.anyOf !== undefined
|
|
@@ -685,8 +680,8 @@ function createEdges({
|
|
|
685
680
|
collapsible: false,
|
|
686
681
|
name,
|
|
687
682
|
required: Array.isArray(required) ? required.includes(name) : required,
|
|
688
|
-
schemaName:
|
|
689
|
-
qualifierMessage: getQualifierMessage(
|
|
683
|
+
schemaName: mergedSchemaName,
|
|
684
|
+
qualifierMessage: getQualifierMessage(mergedSchemas),
|
|
690
685
|
schema: mergedSchemas,
|
|
691
686
|
});
|
|
692
687
|
}
|
|
@@ -817,9 +812,18 @@ export function createNodes(
|
|
|
817
812
|
style: {
|
|
818
813
|
marginTop: ".5rem",
|
|
819
814
|
marginBottom: ".5rem",
|
|
820
|
-
marginLeft: "1rem",
|
|
821
815
|
},
|
|
822
|
-
children:
|
|
816
|
+
children: [
|
|
817
|
+
createDescription(schema.type),
|
|
818
|
+
guard(getQualifierMessage(schema), (message) =>
|
|
819
|
+
create("div", {
|
|
820
|
+
style: {
|
|
821
|
+
paddingTop: "1rem",
|
|
822
|
+
},
|
|
823
|
+
children: createDescription(message),
|
|
824
|
+
})
|
|
825
|
+
),
|
|
826
|
+
],
|
|
823
827
|
});
|
|
824
828
|
}
|
|
825
829
|
|
|
@@ -829,9 +833,18 @@ export function createNodes(
|
|
|
829
833
|
style: {
|
|
830
834
|
marginTop: ".5rem",
|
|
831
835
|
marginBottom: ".5rem",
|
|
832
|
-
marginLeft: "1rem",
|
|
833
836
|
},
|
|
834
|
-
children: [
|
|
837
|
+
children: [
|
|
838
|
+
createDescription(schema),
|
|
839
|
+
guard(getQualifierMessage(schema), (message) =>
|
|
840
|
+
create("div", {
|
|
841
|
+
style: {
|
|
842
|
+
paddingTop: "1rem",
|
|
843
|
+
},
|
|
844
|
+
children: createDescription(message),
|
|
845
|
+
})
|
|
846
|
+
),
|
|
847
|
+
],
|
|
835
848
|
});
|
|
836
849
|
}
|
|
837
850
|
|
package/src/markdown/schema.ts
CHANGED
package/src/sidebars/index.ts
CHANGED