docusaurus-plugin-openapi-docs 1.5.2 → 1.6.1
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/README.md +20 -19
- package/lib/index.js +5 -0
- package/lib/markdown/createAuthentication.js +45 -13
- package/lib/markdown/createRequestSchema.js +35 -20
- package/lib/markdown/createResponseSchema.js +39 -22
- package/lib/markdown/createStatusCodes.js +3 -1
- package/lib/markdown/index.js +1 -1
- package/lib/markdown/utils.js +2 -2
- package/lib/openapi/createRequestExample.js +1 -1
- package/lib/openapi/createResponseExample.js +1 -1
- package/lib/openapi/openapi.js +7 -1
- package/lib/openapi/utils/loadAndResolveSpec.js +13 -0
- package/lib/options.js +3 -1
- package/lib/sidebars/index.js +3 -1
- package/lib/types.d.ts +1 -0
- package/package.json +8 -8
- package/src/index.ts +6 -0
- package/src/markdown/createAuthentication.ts +53 -17
- package/src/markdown/createRequestSchema.ts +104 -23
- package/src/markdown/createResponseSchema.ts +119 -34
- package/src/markdown/createStatusCodes.ts +38 -39
- package/src/markdown/index.ts +1 -1
- package/src/markdown/utils.ts +2 -2
- package/src/openapi/createRequestExample.ts +1 -1
- package/src/openapi/createResponseExample.ts +1 -1
- package/src/openapi/openapi.ts +7 -1
- package/src/openapi/utils/loadAndResolveSpec.ts +15 -0
- package/src/options.ts +3 -1
- package/src/sidebars/index.ts +6 -1
- package/src/types.ts +1 -0
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": "1.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"watch": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/module-type-aliases": "
|
|
32
|
-
"@docusaurus/types": "
|
|
31
|
+
"@docusaurus/module-type-aliases": ">=2.0.1 <2.3.0",
|
|
32
|
+
"@docusaurus/types": ">=2.0.1 <2.3.0",
|
|
33
33
|
"@types/fs-extra": "^9.0.13",
|
|
34
34
|
"@types/js-yaml": "^4.0.5",
|
|
35
35
|
"@types/json-pointer": "^1.0.31",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@apidevtools/json-schema-ref-parser": "^9.0.9",
|
|
43
|
-
"@docusaurus/mdx-loader": "
|
|
44
|
-
"@docusaurus/plugin-content-docs": "
|
|
45
|
-
"@docusaurus/utils": "
|
|
46
|
-
"@docusaurus/utils-validation": "
|
|
43
|
+
"@docusaurus/mdx-loader": ">=2.0.1 <2.3.0",
|
|
44
|
+
"@docusaurus/plugin-content-docs": ">=2.0.1 <2.3.0",
|
|
45
|
+
"@docusaurus/utils": ">=2.0.1 <2.3.0",
|
|
46
|
+
"@docusaurus/utils-validation": ">=2.0.1 <2.3.0",
|
|
47
47
|
"@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
|
|
48
48
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
49
49
|
"@redocly/openapi-core": "^1.0.0-beta.103",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "68f648d80d41b82a607215bac0a082f931f80b7c"
|
|
72
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -94,6 +94,9 @@ export default function pluginOpenAPIDocs(
|
|
|
94
94
|
let { specPath, outputDir, template, downloadUrl, sidebarOptions } =
|
|
95
95
|
options;
|
|
96
96
|
|
|
97
|
+
// Remove trailing slash before proceeding
|
|
98
|
+
outputDir = outputDir.replace(/\/$/, "");
|
|
99
|
+
|
|
97
100
|
// Override docPath if pluginId provided
|
|
98
101
|
if (pluginId) {
|
|
99
102
|
docData = getDocsPluginConfig(presetsPlugins, pluginId);
|
|
@@ -187,6 +190,9 @@ custom_edit_url: null
|
|
|
187
190
|
{{#frontMatter.proxy}}
|
|
188
191
|
proxy: {{{frontMatter.proxy}}}
|
|
189
192
|
{{/frontMatter.proxy}}
|
|
193
|
+
{{#frontMatter.hide_send_button}}
|
|
194
|
+
hide_send_button: true
|
|
195
|
+
{{/frontMatter.hide_send_button}}
|
|
190
196
|
---
|
|
191
197
|
|
|
192
198
|
{{{markdown}}}
|
|
@@ -13,7 +13,8 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
13
13
|
if (!securitySchemes || !Object.keys(securitySchemes).length) return "";
|
|
14
14
|
|
|
15
15
|
const createAuthenticationTable = (securityScheme: any) => {
|
|
16
|
-
const { bearerFormat, flows, name, scheme, type } =
|
|
16
|
+
const { bearerFormat, flows, name, scheme, type, openIdConnectUrl } =
|
|
17
|
+
securityScheme;
|
|
17
18
|
|
|
18
19
|
const createSecuritySchemeTypeRow = () =>
|
|
19
20
|
create("tr", {
|
|
@@ -30,7 +31,7 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
30
31
|
|
|
31
32
|
return create("tr", {
|
|
32
33
|
children: [
|
|
33
|
-
create("th", { children:
|
|
34
|
+
create("th", { children: `OAuth Flow (${flowType}):` }),
|
|
34
35
|
create("td", {
|
|
35
36
|
children: [
|
|
36
37
|
guard(tokenUrl, () =>
|
|
@@ -91,12 +92,14 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
91
92
|
create("td", { children: scheme }),
|
|
92
93
|
],
|
|
93
94
|
}),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
guard(bearerFormat, () =>
|
|
96
|
+
create("tr", {
|
|
97
|
+
children: [
|
|
98
|
+
create("th", { children: "Bearer format:" }),
|
|
99
|
+
create("td", { children: bearerFormat }),
|
|
100
|
+
],
|
|
101
|
+
})
|
|
102
|
+
),
|
|
100
103
|
],
|
|
101
104
|
}),
|
|
102
105
|
}),
|
|
@@ -115,23 +118,51 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
115
118
|
}),
|
|
116
119
|
],
|
|
117
120
|
});
|
|
121
|
+
case "openIdConnect":
|
|
122
|
+
return create("div", {
|
|
123
|
+
children: [
|
|
124
|
+
create("table", {
|
|
125
|
+
children: create("tbody", {
|
|
126
|
+
children: [
|
|
127
|
+
createSecuritySchemeTypeRow(),
|
|
128
|
+
guard(openIdConnectUrl, () =>
|
|
129
|
+
create("tr", {
|
|
130
|
+
children: [
|
|
131
|
+
create("th", { children: "OpenID Connect URL:" }),
|
|
132
|
+
create("td", { children: openIdConnectUrl }),
|
|
133
|
+
],
|
|
134
|
+
})
|
|
135
|
+
),
|
|
136
|
+
],
|
|
137
|
+
}),
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
});
|
|
118
141
|
default:
|
|
119
142
|
return "";
|
|
120
143
|
}
|
|
121
144
|
};
|
|
122
145
|
|
|
123
|
-
const formatTabLabel = (
|
|
124
|
-
const formattedLabel =
|
|
146
|
+
const formatTabLabel = (key: string, type: string, scheme: string) => {
|
|
147
|
+
const formattedLabel = key
|
|
125
148
|
.replace(/(_|-)/g, " ")
|
|
126
149
|
.trim()
|
|
127
150
|
.replace(/\w\S*/g, (str) => str.charAt(0).toUpperCase() + str.substr(1))
|
|
128
151
|
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
129
152
|
.replace(/([A-Z])([A-Z][a-z])/g, "$1 $2");
|
|
153
|
+
const isOAuth = type === "oauth2";
|
|
154
|
+
const isApiKey = type === "apiKey";
|
|
155
|
+
const isHttpBasic = type === "http" && scheme === "basic";
|
|
156
|
+
const isHttpBearer = type === "http" && scheme === "bearer";
|
|
157
|
+
const isOpenId = type === "openIdConnect";
|
|
130
158
|
|
|
131
|
-
|
|
132
|
-
|
|
159
|
+
if (isOAuth) return `OAuth 2.0: ${key}`;
|
|
160
|
+
if (isApiKey) return `API Key: ${key}`;
|
|
161
|
+
if (isHttpBasic) return "HTTP: Basic Auth";
|
|
162
|
+
if (isHttpBearer) return "HTTP: Bearer Auth";
|
|
163
|
+
if (isOpenId) return `OpenID Connect: ${key}`;
|
|
133
164
|
|
|
134
|
-
return
|
|
165
|
+
return formattedLabel;
|
|
135
166
|
};
|
|
136
167
|
|
|
137
168
|
return create("div", {
|
|
@@ -141,12 +172,17 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
141
172
|
id: "authentication",
|
|
142
173
|
style: { marginBottom: "1rem" },
|
|
143
174
|
}),
|
|
144
|
-
create("
|
|
175
|
+
create("SchemaTabs", {
|
|
176
|
+
className: "openapi-tabs__security-schemes",
|
|
145
177
|
children: Object.entries(securitySchemes).map(
|
|
146
|
-
([
|
|
178
|
+
([schemeKey, schemeObj]) =>
|
|
147
179
|
create("TabItem", {
|
|
148
|
-
label: formatTabLabel(
|
|
149
|
-
|
|
180
|
+
label: formatTabLabel(
|
|
181
|
+
schemeKey,
|
|
182
|
+
schemeObj.type,
|
|
183
|
+
schemeObj.scheme
|
|
184
|
+
),
|
|
185
|
+
value: `${schemeKey}`,
|
|
150
186
|
children: [
|
|
151
187
|
createDescription(schemeObj.description),
|
|
152
188
|
createAuthenticationTable(schemeObj),
|
|
@@ -34,7 +34,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
34
34
|
return true;
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
-
ignoreAdditionalProperties:
|
|
37
|
+
ignoreAdditionalProperties: false,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
const required = allOf.reduce((acc, cur) => {
|
|
@@ -157,6 +157,28 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
157
157
|
// },
|
|
158
158
|
// type: 'array'
|
|
159
159
|
// }
|
|
160
|
+
const additionalProperties = schema.additionalProperties;
|
|
161
|
+
const type: string | unknown = additionalProperties?.type;
|
|
162
|
+
if (
|
|
163
|
+
(type === "object" || type === "array") &&
|
|
164
|
+
(additionalProperties?.properties ||
|
|
165
|
+
additionalProperties?.items ||
|
|
166
|
+
additionalProperties?.allOf ||
|
|
167
|
+
additionalProperties?.additionalProperties ||
|
|
168
|
+
additionalProperties?.oneOf ||
|
|
169
|
+
additionalProperties?.anyOf)
|
|
170
|
+
) {
|
|
171
|
+
const title = additionalProperties.title;
|
|
172
|
+
const schemaName = title ? `object (${title})` : "object";
|
|
173
|
+
const required = schema.required ?? false;
|
|
174
|
+
return createDetailsNode(
|
|
175
|
+
"property name*",
|
|
176
|
+
schemaName,
|
|
177
|
+
additionalProperties,
|
|
178
|
+
required,
|
|
179
|
+
schema.nullable
|
|
180
|
+
);
|
|
181
|
+
}
|
|
160
182
|
|
|
161
183
|
if (
|
|
162
184
|
(schema.additionalProperties?.type as string) === "string" ||
|
|
@@ -165,7 +187,6 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
165
187
|
(schema.additionalProperties?.type as string) === "integer" ||
|
|
166
188
|
(schema.additionalProperties?.type as string) === "number"
|
|
167
189
|
) {
|
|
168
|
-
const type = schema.additionalProperties?.type;
|
|
169
190
|
const additionalProperties =
|
|
170
191
|
schema.additionalProperties?.additionalProperties;
|
|
171
192
|
if (additionalProperties !== undefined) {
|
|
@@ -436,7 +457,8 @@ function createDetailsNode(
|
|
|
436
457
|
name: string,
|
|
437
458
|
schemaName: string,
|
|
438
459
|
schema: SchemaObject,
|
|
439
|
-
required: string[] | boolean
|
|
460
|
+
required: string[] | boolean,
|
|
461
|
+
nullable: boolean | unknown
|
|
440
462
|
): any {
|
|
441
463
|
return create("SchemaItem", {
|
|
442
464
|
collapsible: true,
|
|
@@ -451,15 +473,19 @@ function createDetailsNode(
|
|
|
451
473
|
style: { opacity: "0.6" },
|
|
452
474
|
children: ` ${schemaName}`,
|
|
453
475
|
}),
|
|
454
|
-
guard(
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
476
|
+
guard(
|
|
477
|
+
(schema.nullable && schema.nullable === true) ||
|
|
478
|
+
(nullable && nullable === true),
|
|
479
|
+
() => [
|
|
480
|
+
create("strong", {
|
|
481
|
+
style: {
|
|
482
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
483
|
+
color: "var(--openapi-nullable)",
|
|
484
|
+
},
|
|
485
|
+
children: " nullable",
|
|
486
|
+
}),
|
|
487
|
+
]
|
|
488
|
+
),
|
|
463
489
|
guard(
|
|
464
490
|
Array.isArray(required)
|
|
465
491
|
? required.includes(name)
|
|
@@ -604,7 +630,13 @@ function createEdges({
|
|
|
604
630
|
}
|
|
605
631
|
|
|
606
632
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
607
|
-
return createDetailsNode(
|
|
633
|
+
return createDetailsNode(
|
|
634
|
+
name,
|
|
635
|
+
schemaName,
|
|
636
|
+
schema,
|
|
637
|
+
required,
|
|
638
|
+
schema.nullable
|
|
639
|
+
);
|
|
608
640
|
}
|
|
609
641
|
|
|
610
642
|
if (schema.allOf !== undefined) {
|
|
@@ -619,20 +651,44 @@ function createEdges({
|
|
|
619
651
|
mergedSchemas.oneOf !== undefined ||
|
|
620
652
|
mergedSchemas.anyOf !== undefined
|
|
621
653
|
) {
|
|
622
|
-
return createDetailsNode(
|
|
654
|
+
return createDetailsNode(
|
|
655
|
+
name,
|
|
656
|
+
mergedSchemaName,
|
|
657
|
+
mergedSchemas,
|
|
658
|
+
required,
|
|
659
|
+
schema.nullable
|
|
660
|
+
);
|
|
623
661
|
}
|
|
624
662
|
|
|
625
663
|
if (mergedSchemas.properties !== undefined) {
|
|
626
|
-
return createDetailsNode(
|
|
664
|
+
return createDetailsNode(
|
|
665
|
+
name,
|
|
666
|
+
mergedSchemaName,
|
|
667
|
+
mergedSchemas,
|
|
668
|
+
required,
|
|
669
|
+
schema.nullable
|
|
670
|
+
);
|
|
627
671
|
}
|
|
628
672
|
|
|
629
673
|
if (mergedSchemas.additionalProperties !== undefined) {
|
|
630
|
-
return createDetailsNode(
|
|
674
|
+
return createDetailsNode(
|
|
675
|
+
name,
|
|
676
|
+
mergedSchemaName,
|
|
677
|
+
mergedSchemas,
|
|
678
|
+
required,
|
|
679
|
+
schema.nullable
|
|
680
|
+
);
|
|
631
681
|
}
|
|
632
682
|
|
|
633
683
|
// array of objects
|
|
634
684
|
if (mergedSchemas.items?.properties !== undefined) {
|
|
635
|
-
return createDetailsNode(
|
|
685
|
+
return createDetailsNode(
|
|
686
|
+
name,
|
|
687
|
+
mergedSchemaName,
|
|
688
|
+
mergedSchemas,
|
|
689
|
+
required,
|
|
690
|
+
schema.nullable
|
|
691
|
+
);
|
|
636
692
|
}
|
|
637
693
|
|
|
638
694
|
if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
|
|
@@ -650,20 +706,44 @@ function createEdges({
|
|
|
650
706
|
}
|
|
651
707
|
|
|
652
708
|
if (schema.properties !== undefined) {
|
|
653
|
-
return createDetailsNode(
|
|
709
|
+
return createDetailsNode(
|
|
710
|
+
name,
|
|
711
|
+
schemaName,
|
|
712
|
+
schema,
|
|
713
|
+
required,
|
|
714
|
+
schema.nullable
|
|
715
|
+
);
|
|
654
716
|
}
|
|
655
717
|
|
|
656
718
|
if (schema.additionalProperties !== undefined) {
|
|
657
|
-
return createDetailsNode(
|
|
719
|
+
return createDetailsNode(
|
|
720
|
+
name,
|
|
721
|
+
schemaName,
|
|
722
|
+
schema,
|
|
723
|
+
required,
|
|
724
|
+
schema.nullable
|
|
725
|
+
);
|
|
658
726
|
}
|
|
659
727
|
|
|
660
728
|
// array of objects
|
|
661
729
|
if (schema.items?.properties !== undefined) {
|
|
662
|
-
return createDetailsNode(
|
|
730
|
+
return createDetailsNode(
|
|
731
|
+
name,
|
|
732
|
+
schemaName,
|
|
733
|
+
schema,
|
|
734
|
+
required,
|
|
735
|
+
schema.nullable
|
|
736
|
+
);
|
|
663
737
|
}
|
|
664
738
|
|
|
665
739
|
if (schema.items?.anyOf !== undefined || schema.items?.oneOf !== undefined) {
|
|
666
|
-
return createDetailsNode(
|
|
740
|
+
return createDetailsNode(
|
|
741
|
+
name,
|
|
742
|
+
schemaName,
|
|
743
|
+
schema,
|
|
744
|
+
required,
|
|
745
|
+
schema.nullable
|
|
746
|
+
);
|
|
667
747
|
}
|
|
668
748
|
|
|
669
749
|
if (schema.readOnly && schema.readOnly === true) {
|
|
@@ -751,7 +831,7 @@ function createNodes(schema: SchemaObject): any {
|
|
|
751
831
|
|
|
752
832
|
// Unknown node/schema type should return undefined
|
|
753
833
|
// So far, haven't seen this hit in testing
|
|
754
|
-
return
|
|
834
|
+
return "any";
|
|
755
835
|
}
|
|
756
836
|
|
|
757
837
|
interface Props {
|
|
@@ -840,7 +920,8 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
840
920
|
}
|
|
841
921
|
|
|
842
922
|
const randomFirstKey = Object.keys(body.content)[0];
|
|
843
|
-
const firstBody =
|
|
923
|
+
const firstBody: any =
|
|
924
|
+
body.content[randomFirstKey].schema ?? body.content![randomFirstKey];
|
|
844
925
|
|
|
845
926
|
if (firstBody === undefined) {
|
|
846
927
|
return undefined;
|
|
@@ -163,6 +163,28 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
163
163
|
// },
|
|
164
164
|
// type: 'array'
|
|
165
165
|
// }
|
|
166
|
+
const additionalProperties = schema.additionalProperties;
|
|
167
|
+
const type: string | unknown = additionalProperties?.type;
|
|
168
|
+
if (
|
|
169
|
+
(type === "object" || type === "array") &&
|
|
170
|
+
(additionalProperties?.properties ||
|
|
171
|
+
additionalProperties?.items ||
|
|
172
|
+
additionalProperties?.allOf ||
|
|
173
|
+
additionalProperties?.additionalProperties ||
|
|
174
|
+
additionalProperties?.oneOf ||
|
|
175
|
+
additionalProperties?.anyOf)
|
|
176
|
+
) {
|
|
177
|
+
const title = additionalProperties.title;
|
|
178
|
+
const schemaName = title ? `object (${title})` : "object";
|
|
179
|
+
const required = schema.required ?? false;
|
|
180
|
+
return createDetailsNode(
|
|
181
|
+
"property name*",
|
|
182
|
+
schemaName,
|
|
183
|
+
additionalProperties,
|
|
184
|
+
required,
|
|
185
|
+
schema.nullable
|
|
186
|
+
);
|
|
187
|
+
}
|
|
166
188
|
|
|
167
189
|
if (
|
|
168
190
|
(schema.additionalProperties?.type as string) === "string" ||
|
|
@@ -171,7 +193,6 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
171
193
|
(schema.additionalProperties?.type as string) === "integer" ||
|
|
172
194
|
(schema.additionalProperties?.type as string) === "number"
|
|
173
195
|
) {
|
|
174
|
-
const type = schema.additionalProperties?.type;
|
|
175
196
|
const additionalProperties =
|
|
176
197
|
schema.additionalProperties?.additionalProperties;
|
|
177
198
|
if (additionalProperties !== undefined) {
|
|
@@ -442,7 +463,8 @@ function createDetailsNode(
|
|
|
442
463
|
name: string,
|
|
443
464
|
schemaName: string,
|
|
444
465
|
schema: SchemaObject,
|
|
445
|
-
required: string[] | boolean
|
|
466
|
+
required: string[] | boolean,
|
|
467
|
+
nullable: boolean | unknown
|
|
446
468
|
): any {
|
|
447
469
|
return create("SchemaItem", {
|
|
448
470
|
collapsible: true,
|
|
@@ -457,24 +479,33 @@ function createDetailsNode(
|
|
|
457
479
|
style: { opacity: "0.6" },
|
|
458
480
|
children: ` ${schemaName}`,
|
|
459
481
|
}),
|
|
460
|
-
guard(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
482
|
+
guard(
|
|
483
|
+
(schema.nullable && schema.nullable === true) ||
|
|
484
|
+
(nullable && nullable === true),
|
|
485
|
+
() => [
|
|
486
|
+
create("strong", {
|
|
487
|
+
style: {
|
|
488
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
489
|
+
color: "var(--openapi-nullable)",
|
|
490
|
+
},
|
|
491
|
+
children: " nullable",
|
|
492
|
+
}),
|
|
493
|
+
]
|
|
494
|
+
),
|
|
495
|
+
guard(
|
|
496
|
+
Array.isArray(required)
|
|
497
|
+
? required.includes(name)
|
|
498
|
+
: required === true,
|
|
499
|
+
() => [
|
|
500
|
+
create("strong", {
|
|
501
|
+
style: {
|
|
502
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
503
|
+
color: "var(--openapi-required)",
|
|
504
|
+
},
|
|
505
|
+
children: " required",
|
|
506
|
+
}),
|
|
507
|
+
]
|
|
508
|
+
),
|
|
478
509
|
],
|
|
479
510
|
}),
|
|
480
511
|
create("div", {
|
|
@@ -605,7 +636,13 @@ function createEdges({
|
|
|
605
636
|
}
|
|
606
637
|
|
|
607
638
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
608
|
-
return createDetailsNode(
|
|
639
|
+
return createDetailsNode(
|
|
640
|
+
name,
|
|
641
|
+
schemaName,
|
|
642
|
+
schema,
|
|
643
|
+
required,
|
|
644
|
+
schema.nullable
|
|
645
|
+
);
|
|
609
646
|
}
|
|
610
647
|
|
|
611
648
|
if (schema.allOf !== undefined) {
|
|
@@ -620,20 +657,44 @@ function createEdges({
|
|
|
620
657
|
mergedSchemas.oneOf !== undefined ||
|
|
621
658
|
mergedSchemas.anyOf !== undefined
|
|
622
659
|
) {
|
|
623
|
-
return createDetailsNode(
|
|
660
|
+
return createDetailsNode(
|
|
661
|
+
name,
|
|
662
|
+
mergedSchemaName,
|
|
663
|
+
mergedSchemas,
|
|
664
|
+
required,
|
|
665
|
+
schema.nullable
|
|
666
|
+
);
|
|
624
667
|
}
|
|
625
668
|
|
|
626
669
|
if (mergedSchemas.properties !== undefined) {
|
|
627
|
-
return createDetailsNode(
|
|
670
|
+
return createDetailsNode(
|
|
671
|
+
name,
|
|
672
|
+
mergedSchemaName,
|
|
673
|
+
mergedSchemas,
|
|
674
|
+
required,
|
|
675
|
+
schema.nullable
|
|
676
|
+
);
|
|
628
677
|
}
|
|
629
678
|
|
|
630
679
|
if (mergedSchemas.additionalProperties !== undefined) {
|
|
631
|
-
return createDetailsNode(
|
|
680
|
+
return createDetailsNode(
|
|
681
|
+
name,
|
|
682
|
+
mergedSchemaName,
|
|
683
|
+
mergedSchemas,
|
|
684
|
+
required,
|
|
685
|
+
schema.nullable
|
|
686
|
+
);
|
|
632
687
|
}
|
|
633
688
|
|
|
634
689
|
// array of objects
|
|
635
690
|
if (mergedSchemas.items?.properties !== undefined) {
|
|
636
|
-
return createDetailsNode(
|
|
691
|
+
return createDetailsNode(
|
|
692
|
+
name,
|
|
693
|
+
mergedSchemaName,
|
|
694
|
+
mergedSchemas,
|
|
695
|
+
required,
|
|
696
|
+
schema.nullable
|
|
697
|
+
);
|
|
637
698
|
}
|
|
638
699
|
|
|
639
700
|
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
@@ -643,7 +704,7 @@ function createEdges({
|
|
|
643
704
|
return create("SchemaItem", {
|
|
644
705
|
collapsible: false,
|
|
645
706
|
name,
|
|
646
|
-
required:
|
|
707
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
647
708
|
schemaName: schemaName,
|
|
648
709
|
qualifierMessage: getQualifierMessage(schema),
|
|
649
710
|
schema: mergedSchemas,
|
|
@@ -651,20 +712,44 @@ function createEdges({
|
|
|
651
712
|
}
|
|
652
713
|
|
|
653
714
|
if (schema.properties !== undefined) {
|
|
654
|
-
return createDetailsNode(
|
|
715
|
+
return createDetailsNode(
|
|
716
|
+
name,
|
|
717
|
+
schemaName,
|
|
718
|
+
schema,
|
|
719
|
+
required,
|
|
720
|
+
schema.nullable
|
|
721
|
+
);
|
|
655
722
|
}
|
|
656
723
|
|
|
657
724
|
if (schema.additionalProperties !== undefined) {
|
|
658
|
-
return createDetailsNode(
|
|
725
|
+
return createDetailsNode(
|
|
726
|
+
name,
|
|
727
|
+
schemaName,
|
|
728
|
+
schema,
|
|
729
|
+
required,
|
|
730
|
+
schema.nullable
|
|
731
|
+
);
|
|
659
732
|
}
|
|
660
733
|
|
|
661
734
|
// array of objects
|
|
662
735
|
if (schema.items?.properties !== undefined) {
|
|
663
|
-
return createDetailsNode(
|
|
736
|
+
return createDetailsNode(
|
|
737
|
+
name,
|
|
738
|
+
schemaName,
|
|
739
|
+
schema,
|
|
740
|
+
required,
|
|
741
|
+
schema.nullable
|
|
742
|
+
);
|
|
664
743
|
}
|
|
665
744
|
|
|
666
745
|
if (schema.items?.anyOf !== undefined || schema.items?.oneOf !== undefined) {
|
|
667
|
-
return createDetailsNode(
|
|
746
|
+
return createDetailsNode(
|
|
747
|
+
name,
|
|
748
|
+
schemaName,
|
|
749
|
+
schema,
|
|
750
|
+
required,
|
|
751
|
+
schema.nullable
|
|
752
|
+
);
|
|
668
753
|
}
|
|
669
754
|
|
|
670
755
|
if (schema.writeOnly && schema.writeOnly === true) {
|
|
@@ -675,7 +760,7 @@ function createEdges({
|
|
|
675
760
|
return create("SchemaItem", {
|
|
676
761
|
collapsible: false,
|
|
677
762
|
name,
|
|
678
|
-
required:
|
|
763
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
679
764
|
schemaName: schemaName,
|
|
680
765
|
qualifierMessage: getQualifierMessage(schema),
|
|
681
766
|
schema: schema,
|
|
@@ -697,7 +782,6 @@ function createNodes(schema: SchemaObject): any {
|
|
|
697
782
|
|
|
698
783
|
if (schema.allOf !== undefined) {
|
|
699
784
|
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
700
|
-
|
|
701
785
|
if (mergedSchemas.properties !== undefined) {
|
|
702
786
|
nodes.push(createProperties(mergedSchemas));
|
|
703
787
|
}
|
|
@@ -755,7 +839,7 @@ function createNodes(schema: SchemaObject): any {
|
|
|
755
839
|
|
|
756
840
|
// Unknown node/schema type should return undefined
|
|
757
841
|
// So far, haven't seen this hit in testing
|
|
758
|
-
return
|
|
842
|
+
return "any";
|
|
759
843
|
}
|
|
760
844
|
|
|
761
845
|
interface Props {
|
|
@@ -789,7 +873,8 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
789
873
|
children: mimeTypes.map((mimeType: any) => {
|
|
790
874
|
const responseExamples = body.content![mimeType].examples;
|
|
791
875
|
const responseExample = body.content![mimeType].example;
|
|
792
|
-
const firstBody =
|
|
876
|
+
const firstBody: any =
|
|
877
|
+
body.content![mimeType].schema ?? body.content![mimeType];
|
|
793
878
|
|
|
794
879
|
if (
|
|
795
880
|
firstBody === undefined &&
|