docusaurus-plugin-openapi-docs 0.0.0-beta.654 → 0.0.0-beta.656
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/createParamsDetails.js +2 -1
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +13 -0
- package/lib/markdown/createRequestSchema.js +62 -52
- package/lib/markdown/createResponseSchema.js +52 -49
- package/lib/markdown/index.js +3 -2
- package/package.json +2 -2
- package/src/markdown/createParamsDetails.ts +2 -1
- package/src/markdown/createRequestHeader.ts +10 -0
- package/src/markdown/createRequestSchema.ts +66 -66
- package/src/markdown/createResponseSchema.ts +56 -64
- package/src/markdown/index.ts +3 -2
|
@@ -26,7 +26,8 @@ function createParamsDetails({ parameters, type }) {
|
|
|
26
26
|
children: [
|
|
27
27
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
28
28
|
children: [
|
|
29
|
-
(0, utils_1.create)("
|
|
29
|
+
(0, utils_1.create)("h3", {
|
|
30
|
+
className: "openapi-markdown__details-summary-header-params",
|
|
30
31
|
children: `${type.charAt(0).toUpperCase() + type.slice(1)} Parameters`,
|
|
31
32
|
}),
|
|
32
33
|
],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createRequestHeader(header: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createRequestHeader = void 0;
|
|
10
|
+
function createRequestHeader(header) {
|
|
11
|
+
return `## ${header}\n\n`;
|
|
12
|
+
}
|
|
13
|
+
exports.createRequestHeader = createRequestHeader;
|
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.createRequestSchema = exports.mergeAllOf = void 0;
|
|
13
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
14
|
const createArrayBracket_1 = require("./createArrayBracket");
|
|
11
15
|
const createDescription_1 = require("./createDescription");
|
|
12
16
|
const createDetails_1 = require("./createDetails");
|
|
@@ -47,7 +51,7 @@ exports.mergeAllOf = mergeAllOf;
|
|
|
47
51
|
*/
|
|
48
52
|
function createAnyOneOf(schema) {
|
|
49
53
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
50
|
-
return (0, utils_1.create)("
|
|
54
|
+
return (0, utils_1.create)("div", {
|
|
51
55
|
children: [
|
|
52
56
|
(0, utils_1.create)("span", {
|
|
53
57
|
className: "badge badge--info",
|
|
@@ -61,12 +65,15 @@ function createAnyOneOf(schema) {
|
|
|
61
65
|
const anyOneChildren = [];
|
|
62
66
|
if (anyOneSchema.properties !== undefined) {
|
|
63
67
|
anyOneChildren.push(createProperties(anyOneSchema));
|
|
68
|
+
delete anyOneSchema.properties;
|
|
64
69
|
}
|
|
65
70
|
if (anyOneSchema.allOf !== undefined) {
|
|
66
71
|
anyOneChildren.push(createNodes(anyOneSchema));
|
|
72
|
+
delete anyOneSchema.allOf;
|
|
67
73
|
}
|
|
68
74
|
if (anyOneSchema.items !== undefined) {
|
|
69
75
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
76
|
+
delete anyOneSchema.items;
|
|
70
77
|
}
|
|
71
78
|
if (anyOneSchema.type === "string" ||
|
|
72
79
|
anyOneSchema.type === "number" ||
|
|
@@ -144,6 +151,18 @@ function createAdditionalProperties(schema) {
|
|
|
144
151
|
// }
|
|
145
152
|
const additionalProperties = schema.additionalProperties;
|
|
146
153
|
const type = additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.type;
|
|
154
|
+
// Handle free-form objects
|
|
155
|
+
if (String(additionalProperties) === "true" && schema.type === "object") {
|
|
156
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
157
|
+
name: "property name*",
|
|
158
|
+
required: false,
|
|
159
|
+
schemaName: "any",
|
|
160
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
161
|
+
schema: schema,
|
|
162
|
+
collapsible: false,
|
|
163
|
+
discriminator: false,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
147
166
|
if ((type === "object" || type === "array") &&
|
|
148
167
|
((additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.properties) ||
|
|
149
168
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.items) ||
|
|
@@ -152,9 +171,9 @@ function createAdditionalProperties(schema) {
|
|
|
152
171
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.oneOf) ||
|
|
153
172
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.anyOf))) {
|
|
154
173
|
const title = additionalProperties.title;
|
|
155
|
-
const schemaName =
|
|
174
|
+
const schemaName = (0, schema_1.getSchemaName)(additionalProperties);
|
|
156
175
|
const required = (_a = schema.required) !== null && _a !== void 0 ? _a : false;
|
|
157
|
-
return createDetailsNode("property name*", schemaName, additionalProperties, required, schema.nullable);
|
|
176
|
+
return createDetailsNode("property name*", title !== null && title !== void 0 ? title : schemaName, additionalProperties, required, schema.nullable);
|
|
158
177
|
}
|
|
159
178
|
if (((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "string" ||
|
|
160
179
|
((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "object" ||
|
|
@@ -164,41 +183,26 @@ function createAdditionalProperties(schema) {
|
|
|
164
183
|
const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
|
|
165
184
|
if (additionalProperties !== undefined) {
|
|
166
185
|
const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
|
|
167
|
-
const
|
|
168
|
-
return (0, utils_1.create)("
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
(0, utils_1.guard)(format, (format) => (0, utils_1.create)("span", {
|
|
177
|
-
style: { opacity: "0.6" },
|
|
178
|
-
children: ` (${format})`,
|
|
179
|
-
})),
|
|
180
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
|
|
181
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
182
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
183
|
-
})),
|
|
184
|
-
],
|
|
185
|
-
}),
|
|
186
|
+
const schemaName = (0, schema_1.getSchemaName)((_k = schema.additionalProperties) === null || _k === void 0 ? void 0 : _k.additionalProperties);
|
|
187
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
188
|
+
name: "property name*",
|
|
189
|
+
required: false,
|
|
190
|
+
schemaName: schemaName !== null && schemaName !== void 0 ? schemaName : type,
|
|
191
|
+
qualifierMessage: (_l = schema.additionalProperties) !== null && _l !== void 0 ? _l : (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
192
|
+
schema: schema,
|
|
193
|
+
collapsible: false,
|
|
194
|
+
discriminator: false,
|
|
186
195
|
});
|
|
187
196
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
198
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
199
|
-
})),
|
|
200
|
-
],
|
|
201
|
-
}),
|
|
197
|
+
const schemaName = (0, schema_1.getSchemaName)(schema.additionalProperties);
|
|
198
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
199
|
+
name: "property name*",
|
|
200
|
+
required: false,
|
|
201
|
+
schemaName: schemaName,
|
|
202
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
203
|
+
schema: schema.additionalProperties,
|
|
204
|
+
collapsible: false,
|
|
205
|
+
discriminator: false,
|
|
202
206
|
});
|
|
203
207
|
}
|
|
204
208
|
return Object.entries(schema.additionalProperties).map(([key, val]) => createEdges({
|
|
@@ -400,8 +404,8 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
400
404
|
className: "openapi-schema__container",
|
|
401
405
|
children: [
|
|
402
406
|
(0, utils_1.create)("strong", {
|
|
403
|
-
|
|
404
|
-
|
|
407
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
408
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
405
409
|
}),
|
|
406
410
|
children: name,
|
|
407
411
|
}),
|
|
@@ -420,7 +424,7 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
420
424
|
]),
|
|
421
425
|
(0, utils_1.guard)(nullable, () => [
|
|
422
426
|
(0, utils_1.create)("span", {
|
|
423
|
-
className: "
|
|
427
|
+
className: "openapi-schema__nullable",
|
|
424
428
|
children: "nullable",
|
|
425
429
|
}),
|
|
426
430
|
]),
|
|
@@ -428,13 +432,13 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
428
432
|
? required.includes(name)
|
|
429
433
|
: required === true, () => [
|
|
430
434
|
(0, utils_1.create)("span", {
|
|
431
|
-
className: "
|
|
435
|
+
className: "openapi-schema__required",
|
|
432
436
|
children: "required",
|
|
433
437
|
}),
|
|
434
438
|
]),
|
|
435
439
|
(0, utils_1.guard)(schema.deprecated, () => [
|
|
436
440
|
(0, utils_1.create)("span", {
|
|
437
|
-
className: "
|
|
441
|
+
className: "openapi-schema__deprecated",
|
|
438
442
|
children: "deprecated",
|
|
439
443
|
}),
|
|
440
444
|
]),
|
|
@@ -473,14 +477,14 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
473
477
|
return undefined;
|
|
474
478
|
}
|
|
475
479
|
return (0, utils_1.create)("div", {
|
|
476
|
-
className: "openapi-discriminator__item",
|
|
480
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
477
481
|
children: (0, utils_1.create)("div", {
|
|
478
482
|
children: [
|
|
479
483
|
(0, utils_1.create)("span", {
|
|
480
484
|
className: "openapi-schema__container",
|
|
481
485
|
children: [
|
|
482
486
|
(0, utils_1.create)("strong", {
|
|
483
|
-
className: "openapi-discriminator__name",
|
|
487
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
484
488
|
children: name,
|
|
485
489
|
}),
|
|
486
490
|
(0, utils_1.guard)(schemaName, (name) => (0, utils_1.create)("span", {
|
|
@@ -489,7 +493,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
489
493
|
})),
|
|
490
494
|
(0, utils_1.guard)(required, () => [
|
|
491
495
|
(0, utils_1.create)("span", {
|
|
492
|
-
className: "
|
|
496
|
+
className: "openapi-schema__required",
|
|
493
497
|
children: "required",
|
|
494
498
|
}),
|
|
495
499
|
]),
|
|
@@ -676,18 +680,21 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
676
680
|
value: `${mimeType}`,
|
|
677
681
|
children: [
|
|
678
682
|
(0, createDetails_1.createDetails)({
|
|
679
|
-
className: "openapi-markdown__details",
|
|
683
|
+
className: "openapi-markdown__details mime",
|
|
680
684
|
"data-collapsed": false,
|
|
681
685
|
open: true,
|
|
682
686
|
...rest,
|
|
683
687
|
children: [
|
|
684
688
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
685
|
-
|
|
689
|
+
className: "openapi-markdown__details-summary-mime",
|
|
686
690
|
children: [
|
|
687
|
-
(0, utils_1.create)("
|
|
691
|
+
(0, utils_1.create)("h3", {
|
|
692
|
+
className: "openapi-markdown__details-summary-header-body",
|
|
693
|
+
children: `${title}`,
|
|
694
|
+
}),
|
|
688
695
|
(0, utils_1.guard)(body.required && body.required === true, () => [
|
|
689
696
|
(0, utils_1.create)("span", {
|
|
690
|
-
className: "
|
|
697
|
+
className: "openapi-schema__required",
|
|
691
698
|
children: "required",
|
|
692
699
|
}),
|
|
693
700
|
]),
|
|
@@ -734,22 +741,25 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
734
741
|
value: `${randomFirstKey}-schema`,
|
|
735
742
|
children: [
|
|
736
743
|
(0, createDetails_1.createDetails)({
|
|
737
|
-
className: "openapi-markdown__details",
|
|
744
|
+
className: "openapi-markdown__details mime",
|
|
738
745
|
"data-collapsed": false,
|
|
739
746
|
open: true,
|
|
740
747
|
...rest,
|
|
741
748
|
children: [
|
|
742
749
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
743
|
-
|
|
750
|
+
className: "openapi-markdown__details-summary-mime",
|
|
744
751
|
children: [
|
|
745
|
-
(0, utils_1.create)("
|
|
752
|
+
(0, utils_1.create)("h3", {
|
|
753
|
+
className: "openapi-markdown__details-summary-header-body",
|
|
754
|
+
children: `${title}`,
|
|
755
|
+
}),
|
|
746
756
|
(0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
|
|
747
757
|
style: { opacity: "0.6" },
|
|
748
758
|
children: ` array`,
|
|
749
759
|
})),
|
|
750
760
|
(0, utils_1.guard)(body.required, () => [
|
|
751
761
|
(0, utils_1.create)("strong", {
|
|
752
|
-
className: "
|
|
762
|
+
className: "openapi-schema__required",
|
|
753
763
|
children: "required",
|
|
754
764
|
}),
|
|
755
765
|
]),
|
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.createResponseSchema = exports.mergeAllOf = void 0;
|
|
13
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
14
|
const createArrayBracket_1 = require("./createArrayBracket");
|
|
11
15
|
const createDescription_1 = require("./createDescription");
|
|
12
16
|
const createDetails_1 = require("./createDetails");
|
|
@@ -48,14 +52,13 @@ exports.mergeAllOf = mergeAllOf;
|
|
|
48
52
|
*/
|
|
49
53
|
function createAnyOneOf(schema) {
|
|
50
54
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
51
|
-
return (0, utils_1.create)("
|
|
55
|
+
return (0, utils_1.create)("div", {
|
|
52
56
|
children: [
|
|
53
57
|
(0, utils_1.create)("span", {
|
|
54
58
|
className: "badge badge--info",
|
|
55
59
|
children: type,
|
|
56
60
|
}),
|
|
57
61
|
(0, utils_1.create)("SchemaTabs", {
|
|
58
|
-
className: "openapi-tabs__schema",
|
|
59
62
|
children: schema[type].map((anyOneSchema, index) => {
|
|
60
63
|
const label = anyOneSchema.title
|
|
61
64
|
? anyOneSchema.title
|
|
@@ -63,12 +66,15 @@ function createAnyOneOf(schema) {
|
|
|
63
66
|
const anyOneChildren = [];
|
|
64
67
|
if (anyOneSchema.properties !== undefined) {
|
|
65
68
|
anyOneChildren.push(createProperties(anyOneSchema));
|
|
69
|
+
delete anyOneSchema.properties;
|
|
66
70
|
}
|
|
67
71
|
if (anyOneSchema.allOf !== undefined) {
|
|
68
72
|
anyOneChildren.push(createNodes(anyOneSchema));
|
|
73
|
+
delete anyOneSchema.allOf;
|
|
69
74
|
}
|
|
70
75
|
if (anyOneSchema.items !== undefined) {
|
|
71
76
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
77
|
+
delete anyOneSchema.items;
|
|
72
78
|
}
|
|
73
79
|
if (anyOneSchema.type === "string" ||
|
|
74
80
|
anyOneSchema.type === "number" ||
|
|
@@ -93,7 +99,7 @@ function createAnyOneOf(schema) {
|
|
|
93
99
|
return (0, utils_1.create)("TabItem", {
|
|
94
100
|
label: label,
|
|
95
101
|
value: `${index}-item-properties`,
|
|
96
|
-
children: anyOneChildren,
|
|
102
|
+
children: anyOneChildren.filter(Boolean).flat(),
|
|
97
103
|
});
|
|
98
104
|
}
|
|
99
105
|
return undefined;
|
|
@@ -146,6 +152,18 @@ function createAdditionalProperties(schema) {
|
|
|
146
152
|
// }
|
|
147
153
|
const additionalProperties = schema.additionalProperties;
|
|
148
154
|
const type = additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.type;
|
|
155
|
+
// Handle free-form objects
|
|
156
|
+
if (String(additionalProperties) === "true" && schema.type === "object") {
|
|
157
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
158
|
+
name: "property name*",
|
|
159
|
+
required: false,
|
|
160
|
+
schemaName: "any",
|
|
161
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
162
|
+
schema: schema,
|
|
163
|
+
collapsible: false,
|
|
164
|
+
discriminator: false,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
149
167
|
if ((type === "object" || type === "array") &&
|
|
150
168
|
((additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.properties) ||
|
|
151
169
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.items) ||
|
|
@@ -154,9 +172,9 @@ function createAdditionalProperties(schema) {
|
|
|
154
172
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.oneOf) ||
|
|
155
173
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.anyOf))) {
|
|
156
174
|
const title = additionalProperties.title;
|
|
157
|
-
const schemaName =
|
|
175
|
+
const schemaName = (0, schema_1.getSchemaName)(additionalProperties);
|
|
158
176
|
const required = (_a = schema.required) !== null && _a !== void 0 ? _a : false;
|
|
159
|
-
return createDetailsNode("property name*", schemaName, additionalProperties, required, schema.nullable);
|
|
177
|
+
return createDetailsNode("property name*", title !== null && title !== void 0 ? title : schemaName, additionalProperties, required, schema.nullable);
|
|
160
178
|
}
|
|
161
179
|
if (((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "string" ||
|
|
162
180
|
((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "object" ||
|
|
@@ -166,41 +184,26 @@ function createAdditionalProperties(schema) {
|
|
|
166
184
|
const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
|
|
167
185
|
if (additionalProperties !== undefined) {
|
|
168
186
|
const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
|
|
169
|
-
const
|
|
170
|
-
return (0, utils_1.create)("
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
(0, utils_1.guard)(format, (format) => (0, utils_1.create)("span", {
|
|
179
|
-
style: { opacity: "0.6" },
|
|
180
|
-
children: ` (${format})`,
|
|
181
|
-
})),
|
|
182
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
|
|
183
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
184
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
185
|
-
})),
|
|
186
|
-
],
|
|
187
|
-
}),
|
|
187
|
+
const schemaName = (0, schema_1.getSchemaName)((_k = schema.additionalProperties) === null || _k === void 0 ? void 0 : _k.additionalProperties);
|
|
188
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
189
|
+
name: "property name*",
|
|
190
|
+
required: false,
|
|
191
|
+
schemaName: schemaName !== null && schemaName !== void 0 ? schemaName : type,
|
|
192
|
+
qualifierMessage: (_l = schema.additionalProperties) !== null && _l !== void 0 ? _l : (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
193
|
+
schema: schema,
|
|
194
|
+
collapsible: false,
|
|
195
|
+
discriminator: false,
|
|
188
196
|
});
|
|
189
197
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
200
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
201
|
-
})),
|
|
202
|
-
],
|
|
203
|
-
}),
|
|
198
|
+
const schemaName = (0, schema_1.getSchemaName)(schema.additionalProperties);
|
|
199
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
200
|
+
name: "property name*",
|
|
201
|
+
required: false,
|
|
202
|
+
schemaName: schemaName,
|
|
203
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
204
|
+
schema: schema.additionalProperties,
|
|
205
|
+
collapsible: false,
|
|
206
|
+
discriminator: false,
|
|
204
207
|
});
|
|
205
208
|
}
|
|
206
209
|
return Object.entries(schema.additionalProperties).map(([key, val]) => createEdges({
|
|
@@ -402,8 +405,8 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
402
405
|
className: "openapi-schema__container",
|
|
403
406
|
children: [
|
|
404
407
|
(0, utils_1.create)("strong", {
|
|
405
|
-
|
|
406
|
-
|
|
408
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
409
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
407
410
|
}),
|
|
408
411
|
children: name,
|
|
409
412
|
}),
|
|
@@ -422,7 +425,7 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
422
425
|
]),
|
|
423
426
|
(0, utils_1.guard)(nullable, () => [
|
|
424
427
|
(0, utils_1.create)("span", {
|
|
425
|
-
className: "
|
|
428
|
+
className: "openapi-schema__nullable",
|
|
426
429
|
children: "nullable",
|
|
427
430
|
}),
|
|
428
431
|
]),
|
|
@@ -430,13 +433,13 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
430
433
|
? required.includes(name)
|
|
431
434
|
: required === true, () => [
|
|
432
435
|
(0, utils_1.create)("span", {
|
|
433
|
-
className: "
|
|
436
|
+
className: "openapi-schema__required",
|
|
434
437
|
children: "required",
|
|
435
438
|
}),
|
|
436
439
|
]),
|
|
437
440
|
(0, utils_1.guard)(schema.deprecated, () => [
|
|
438
441
|
(0, utils_1.create)("span", {
|
|
439
|
-
className: "
|
|
442
|
+
className: "openapi-schema__deprecated",
|
|
440
443
|
children: "deprecated",
|
|
441
444
|
}),
|
|
442
445
|
]),
|
|
@@ -475,14 +478,14 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
475
478
|
return undefined;
|
|
476
479
|
}
|
|
477
480
|
return (0, utils_1.create)("div", {
|
|
478
|
-
className: "openapi-discriminator__item",
|
|
481
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
479
482
|
children: (0, utils_1.create)("div", {
|
|
480
483
|
children: [
|
|
481
484
|
(0, utils_1.create)("span", {
|
|
482
485
|
className: "openapi-schema__container",
|
|
483
486
|
children: [
|
|
484
487
|
(0, utils_1.create)("strong", {
|
|
485
|
-
className: "openapi-discriminator__name",
|
|
488
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
486
489
|
children: name,
|
|
487
490
|
}),
|
|
488
491
|
(0, utils_1.guard)(schemaName, (name) => (0, utils_1.create)("span", {
|
|
@@ -491,7 +494,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
491
494
|
})),
|
|
492
495
|
(0, utils_1.guard)(required, () => [
|
|
493
496
|
(0, utils_1.create)("span", {
|
|
494
|
-
className: "
|
|
497
|
+
className: "openapi-schema__required",
|
|
495
498
|
children: "required",
|
|
496
499
|
}),
|
|
497
500
|
]),
|
|
@@ -694,18 +697,18 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
694
697
|
value: `${title}`,
|
|
695
698
|
children: [
|
|
696
699
|
(0, createDetails_1.createDetails)({
|
|
697
|
-
className: "openapi-markdown__details",
|
|
700
|
+
className: "openapi-markdown__details response",
|
|
698
701
|
"data-collapsed": false,
|
|
699
702
|
open: true,
|
|
700
703
|
...rest,
|
|
701
704
|
children: [
|
|
702
705
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
703
|
-
|
|
706
|
+
className: "openapi-markdown__details-summary-response",
|
|
704
707
|
children: [
|
|
705
708
|
(0, utils_1.create)("strong", { children: `${title}` }),
|
|
706
709
|
(0, utils_1.guard)(body.required && body.required === true, () => [
|
|
707
710
|
(0, utils_1.create)("span", {
|
|
708
|
-
className: "
|
|
711
|
+
className: "openapi-schema__required",
|
|
709
712
|
children: "required",
|
|
710
713
|
}),
|
|
711
714
|
]),
|
package/lib/markdown/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const createLogo_1 = require("./createLogo");
|
|
|
19
19
|
const createMethodEndpoint_1 = require("./createMethodEndpoint");
|
|
20
20
|
const createParamsDetails_1 = require("./createParamsDetails");
|
|
21
21
|
const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
|
|
22
|
+
const createRequestHeader_1 = require("./createRequestHeader");
|
|
22
23
|
const createStatusCodes_1 = require("./createStatusCodes");
|
|
23
24
|
const createTermsOfService_1 = require("./createTermsOfService");
|
|
24
25
|
const createVendorExtensions_1 = require("./createVendorExtensions");
|
|
@@ -38,17 +39,17 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
|
|
|
38
39
|
`import TabItem from "@theme/TabItem";\n\n`,
|
|
39
40
|
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
40
41
|
(0, createMethodEndpoint_1.createMethodEndpoint)(method, path),
|
|
41
|
-
`## ${title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")}\n\n`,
|
|
42
42
|
infoPath && (0, createAuthorization_1.createAuthorization)(infoPath),
|
|
43
43
|
frontMatter.show_extensions && (0, createVendorExtensions_1.createVendorExtensions)(extensions),
|
|
44
44
|
(0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
|
|
45
45
|
(0, createDescription_1.createDescription)(description),
|
|
46
|
+
(0, createRequestHeader_1.createRequestHeader)("Request"),
|
|
46
47
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "path" }),
|
|
47
48
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "query" }),
|
|
48
49
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "header" }),
|
|
49
50
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "cookie" }),
|
|
50
51
|
(0, createRequestBodyDetails_1.createRequestBodyDetails)({
|
|
51
|
-
title: "
|
|
52
|
+
title: "Body",
|
|
52
53
|
body: requestBody,
|
|
53
54
|
}),
|
|
54
55
|
(0, createStatusCodes_1.createStatusCodes)({ responses }),
|
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": "0.0.0-beta.
|
|
4
|
+
"version": "0.0.0-beta.656",
|
|
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": "6c2e5c4c756a07b333560c08616ef0e87516df75"
|
|
64
64
|
}
|
|
@@ -32,7 +32,8 @@ export function createParamsDetails({ parameters, type }: Props) {
|
|
|
32
32
|
children: [
|
|
33
33
|
createDetailsSummary({
|
|
34
34
|
children: [
|
|
35
|
-
create("
|
|
35
|
+
create("h3", {
|
|
36
|
+
className: "openapi-markdown__details-summary-header-params",
|
|
36
37
|
children: `${
|
|
37
38
|
type.charAt(0).toUpperCase() + type.slice(1)
|
|
38
39
|
} Parameters`,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
export function createRequestHeader(header: string) {
|
|
9
|
+
return `## ${header}\n\n`;
|
|
10
|
+
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
|
|
8
10
|
import { MediaTypeObject, SchemaObject } from "../openapi/types";
|
|
9
11
|
import {
|
|
10
12
|
createClosingArrayBracket,
|
|
@@ -53,7 +55,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
53
55
|
*/
|
|
54
56
|
function createAnyOneOf(schema: SchemaObject): any {
|
|
55
57
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
56
|
-
return create("
|
|
58
|
+
return create("div", {
|
|
57
59
|
children: [
|
|
58
60
|
create("span", {
|
|
59
61
|
className: "badge badge--info",
|
|
@@ -68,14 +70,17 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
68
70
|
|
|
69
71
|
if (anyOneSchema.properties !== undefined) {
|
|
70
72
|
anyOneChildren.push(createProperties(anyOneSchema));
|
|
73
|
+
delete anyOneSchema.properties;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
if (anyOneSchema.allOf !== undefined) {
|
|
74
77
|
anyOneChildren.push(createNodes(anyOneSchema));
|
|
78
|
+
delete anyOneSchema.allOf;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
if (anyOneSchema.items !== undefined) {
|
|
78
82
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
83
|
+
delete anyOneSchema.items;
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
if (
|
|
@@ -159,6 +164,18 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
159
164
|
// }
|
|
160
165
|
const additionalProperties = schema.additionalProperties;
|
|
161
166
|
const type: string | unknown = additionalProperties?.type;
|
|
167
|
+
// Handle free-form objects
|
|
168
|
+
if (String(additionalProperties) === "true" && schema.type === "object") {
|
|
169
|
+
return create("SchemaItem", {
|
|
170
|
+
name: "property name*",
|
|
171
|
+
required: false,
|
|
172
|
+
schemaName: "any",
|
|
173
|
+
qualifierMessage: getQualifierMessage(schema.additionalProperties),
|
|
174
|
+
schema: schema,
|
|
175
|
+
collapsible: false,
|
|
176
|
+
discriminator: false,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
162
179
|
if (
|
|
163
180
|
(type === "object" || type === "array") &&
|
|
164
181
|
(additionalProperties?.properties ||
|
|
@@ -168,12 +185,12 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
168
185
|
additionalProperties?.oneOf ||
|
|
169
186
|
additionalProperties?.anyOf)
|
|
170
187
|
) {
|
|
171
|
-
const title = additionalProperties.title;
|
|
172
|
-
const schemaName =
|
|
188
|
+
const title = additionalProperties.title as string;
|
|
189
|
+
const schemaName = getSchemaName(additionalProperties);
|
|
173
190
|
const required = schema.required ?? false;
|
|
174
191
|
return createDetailsNode(
|
|
175
192
|
"property name*",
|
|
176
|
-
schemaName,
|
|
193
|
+
title ?? schemaName,
|
|
177
194
|
additionalProperties,
|
|
178
195
|
required,
|
|
179
196
|
schema.nullable
|
|
@@ -191,51 +208,30 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
191
208
|
schema.additionalProperties?.additionalProperties;
|
|
192
209
|
if (additionalProperties !== undefined) {
|
|
193
210
|
const type = schema.additionalProperties?.additionalProperties?.type;
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
style: { opacity: "0.6" },
|
|
208
|
-
children: ` (${format})`,
|
|
209
|
-
})
|
|
210
|
-
),
|
|
211
|
-
guard(getQualifierMessage(schema.additionalProperties), (message) =>
|
|
212
|
-
create("div", {
|
|
213
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
214
|
-
children: createDescription(message),
|
|
215
|
-
})
|
|
216
|
-
),
|
|
217
|
-
],
|
|
218
|
-
}),
|
|
211
|
+
const schemaName = getSchemaName(
|
|
212
|
+
schema.additionalProperties?.additionalProperties!
|
|
213
|
+
);
|
|
214
|
+
return create("SchemaItem", {
|
|
215
|
+
name: "property name*",
|
|
216
|
+
required: false,
|
|
217
|
+
schemaName: schemaName ?? type,
|
|
218
|
+
qualifierMessage:
|
|
219
|
+
schema.additionalProperties ??
|
|
220
|
+
getQualifierMessage(schema.additionalProperties),
|
|
221
|
+
schema: schema,
|
|
222
|
+
collapsible: false,
|
|
223
|
+
discriminator: false,
|
|
219
224
|
});
|
|
220
225
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
),
|
|
231
|
-
guard(getQualifierMessage(schema.additionalProperties), (message) =>
|
|
232
|
-
create("div", {
|
|
233
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
234
|
-
children: createDescription(message),
|
|
235
|
-
})
|
|
236
|
-
),
|
|
237
|
-
],
|
|
238
|
-
}),
|
|
226
|
+
const schemaName = getSchemaName(schema.additionalProperties!);
|
|
227
|
+
return create("SchemaItem", {
|
|
228
|
+
name: "property name*",
|
|
229
|
+
required: false,
|
|
230
|
+
schemaName: schemaName,
|
|
231
|
+
qualifierMessage: getQualifierMessage(schema),
|
|
232
|
+
schema: schema.additionalProperties,
|
|
233
|
+
collapsible: false,
|
|
234
|
+
discriminator: false,
|
|
239
235
|
});
|
|
240
236
|
}
|
|
241
237
|
return Object.entries(schema.additionalProperties!).map(([key, val]) =>
|
|
@@ -473,8 +469,8 @@ function createDetailsNode(
|
|
|
473
469
|
className: "openapi-schema__container",
|
|
474
470
|
children: [
|
|
475
471
|
create("strong", {
|
|
476
|
-
|
|
477
|
-
|
|
472
|
+
className: clsx("openapi-schema__property", {
|
|
473
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
478
474
|
}),
|
|
479
475
|
children: name,
|
|
480
476
|
}),
|
|
@@ -496,7 +492,7 @@ function createDetailsNode(
|
|
|
496
492
|
),
|
|
497
493
|
guard(nullable, () => [
|
|
498
494
|
create("span", {
|
|
499
|
-
className: "
|
|
495
|
+
className: "openapi-schema__nullable",
|
|
500
496
|
children: "nullable",
|
|
501
497
|
}),
|
|
502
498
|
]),
|
|
@@ -506,16 +502,14 @@ function createDetailsNode(
|
|
|
506
502
|
: required === true,
|
|
507
503
|
() => [
|
|
508
504
|
create("span", {
|
|
509
|
-
className:
|
|
510
|
-
"badge badge--danger openapi-schema__required",
|
|
505
|
+
className: "openapi-schema__required",
|
|
511
506
|
children: "required",
|
|
512
507
|
}),
|
|
513
508
|
]
|
|
514
509
|
),
|
|
515
510
|
guard(schema.deprecated, () => [
|
|
516
511
|
create("span", {
|
|
517
|
-
className:
|
|
518
|
-
"badge badge--warning openapi-schema__deprecated",
|
|
512
|
+
className: "openapi-schema__deprecated",
|
|
519
513
|
children: "deprecated",
|
|
520
514
|
}),
|
|
521
515
|
]),
|
|
@@ -567,14 +561,14 @@ function createPropertyDiscriminator(
|
|
|
567
561
|
}
|
|
568
562
|
|
|
569
563
|
return create("div", {
|
|
570
|
-
className: "openapi-discriminator__item",
|
|
564
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
571
565
|
children: create("div", {
|
|
572
566
|
children: [
|
|
573
567
|
create("span", {
|
|
574
568
|
className: "openapi-schema__container",
|
|
575
569
|
children: [
|
|
576
570
|
create("strong", {
|
|
577
|
-
className: "openapi-discriminator__name",
|
|
571
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
578
572
|
children: name,
|
|
579
573
|
}),
|
|
580
574
|
guard(schemaName, (name) =>
|
|
@@ -585,7 +579,7 @@ function createPropertyDiscriminator(
|
|
|
585
579
|
),
|
|
586
580
|
guard(required, () => [
|
|
587
581
|
create("span", {
|
|
588
|
-
className: "
|
|
582
|
+
className: "openapi-schema__required",
|
|
589
583
|
children: "required",
|
|
590
584
|
}),
|
|
591
585
|
]),
|
|
@@ -901,19 +895,22 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
901
895
|
value: `${mimeType}`,
|
|
902
896
|
children: [
|
|
903
897
|
createDetails({
|
|
904
|
-
className: "openapi-markdown__details",
|
|
898
|
+
className: "openapi-markdown__details mime",
|
|
905
899
|
"data-collapsed": false,
|
|
906
900
|
open: true,
|
|
907
901
|
...rest,
|
|
908
902
|
children: [
|
|
909
903
|
createDetailsSummary({
|
|
910
|
-
|
|
904
|
+
className: "openapi-markdown__details-summary-mime",
|
|
911
905
|
children: [
|
|
912
|
-
create("
|
|
906
|
+
create("h3", {
|
|
907
|
+
className:
|
|
908
|
+
"openapi-markdown__details-summary-header-body",
|
|
909
|
+
children: `${title}`,
|
|
910
|
+
}),
|
|
913
911
|
guard(body.required && body.required === true, () => [
|
|
914
912
|
create("span", {
|
|
915
|
-
className:
|
|
916
|
-
"badge badge--danger openapi-schema__required",
|
|
913
|
+
className: "openapi-schema__required",
|
|
917
914
|
children: "required",
|
|
918
915
|
}),
|
|
919
916
|
]),
|
|
@@ -964,15 +961,18 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
964
961
|
value: `${randomFirstKey}-schema`,
|
|
965
962
|
children: [
|
|
966
963
|
createDetails({
|
|
967
|
-
className: "openapi-markdown__details",
|
|
964
|
+
className: "openapi-markdown__details mime",
|
|
968
965
|
"data-collapsed": false,
|
|
969
966
|
open: true,
|
|
970
967
|
...rest,
|
|
971
968
|
children: [
|
|
972
969
|
createDetailsSummary({
|
|
973
|
-
|
|
970
|
+
className: "openapi-markdown__details-summary-mime",
|
|
974
971
|
children: [
|
|
975
|
-
create("
|
|
972
|
+
create("h3", {
|
|
973
|
+
className: "openapi-markdown__details-summary-header-body",
|
|
974
|
+
children: `${title}`,
|
|
975
|
+
}),
|
|
976
976
|
guard(firstBody.type === "array", (format) =>
|
|
977
977
|
create("span", {
|
|
978
978
|
style: { opacity: "0.6" },
|
|
@@ -981,7 +981,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
981
981
|
),
|
|
982
982
|
guard(body.required, () => [
|
|
983
983
|
create("strong", {
|
|
984
|
-
className: "
|
|
984
|
+
className: "openapi-schema__required",
|
|
985
985
|
children: "required",
|
|
986
986
|
}),
|
|
987
987
|
]),
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import clsx from "clsx";
|
|
9
|
+
|
|
8
10
|
import { MediaTypeObject, SchemaObject } from "../openapi/types";
|
|
9
11
|
import {
|
|
10
12
|
createClosingArrayBracket,
|
|
@@ -58,14 +60,13 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
58
60
|
*/
|
|
59
61
|
function createAnyOneOf(schema: SchemaObject): any {
|
|
60
62
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
61
|
-
return create("
|
|
63
|
+
return create("div", {
|
|
62
64
|
children: [
|
|
63
65
|
create("span", {
|
|
64
66
|
className: "badge badge--info",
|
|
65
67
|
children: type,
|
|
66
68
|
}),
|
|
67
69
|
create("SchemaTabs", {
|
|
68
|
-
className: "openapi-tabs__schema",
|
|
69
70
|
children: schema[type]!.map((anyOneSchema, index) => {
|
|
70
71
|
const label = anyOneSchema.title
|
|
71
72
|
? anyOneSchema.title
|
|
@@ -74,14 +75,17 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
74
75
|
|
|
75
76
|
if (anyOneSchema.properties !== undefined) {
|
|
76
77
|
anyOneChildren.push(createProperties(anyOneSchema));
|
|
78
|
+
delete anyOneSchema.properties;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
if (anyOneSchema.allOf !== undefined) {
|
|
80
82
|
anyOneChildren.push(createNodes(anyOneSchema));
|
|
83
|
+
delete anyOneSchema.allOf;
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
if (anyOneSchema.items !== undefined) {
|
|
84
87
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
88
|
+
delete anyOneSchema.items;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
if (
|
|
@@ -92,7 +96,6 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
92
96
|
) {
|
|
93
97
|
anyOneChildren.push(createNodes(anyOneSchema));
|
|
94
98
|
}
|
|
95
|
-
|
|
96
99
|
if (anyOneChildren.length) {
|
|
97
100
|
if (schema.type === "array") {
|
|
98
101
|
return create("TabItem", {
|
|
@@ -110,7 +113,7 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
110
113
|
return create("TabItem", {
|
|
111
114
|
label: label,
|
|
112
115
|
value: `${index}-item-properties`,
|
|
113
|
-
children: anyOneChildren,
|
|
116
|
+
children: anyOneChildren.filter(Boolean).flat(),
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
119
|
|
|
@@ -166,6 +169,18 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
166
169
|
// }
|
|
167
170
|
const additionalProperties = schema.additionalProperties;
|
|
168
171
|
const type: string | unknown = additionalProperties?.type;
|
|
172
|
+
// Handle free-form objects
|
|
173
|
+
if (String(additionalProperties) === "true" && schema.type === "object") {
|
|
174
|
+
return create("SchemaItem", {
|
|
175
|
+
name: "property name*",
|
|
176
|
+
required: false,
|
|
177
|
+
schemaName: "any",
|
|
178
|
+
qualifierMessage: getQualifierMessage(schema.additionalProperties),
|
|
179
|
+
schema: schema,
|
|
180
|
+
collapsible: false,
|
|
181
|
+
discriminator: false,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
169
184
|
if (
|
|
170
185
|
(type === "object" || type === "array") &&
|
|
171
186
|
(additionalProperties?.properties ||
|
|
@@ -175,12 +190,12 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
175
190
|
additionalProperties?.oneOf ||
|
|
176
191
|
additionalProperties?.anyOf)
|
|
177
192
|
) {
|
|
178
|
-
const title = additionalProperties.title;
|
|
179
|
-
const schemaName =
|
|
193
|
+
const title = additionalProperties.title as string;
|
|
194
|
+
const schemaName = getSchemaName(additionalProperties);
|
|
180
195
|
const required = schema.required ?? false;
|
|
181
196
|
return createDetailsNode(
|
|
182
197
|
"property name*",
|
|
183
|
-
schemaName,
|
|
198
|
+
title ?? schemaName,
|
|
184
199
|
additionalProperties,
|
|
185
200
|
required,
|
|
186
201
|
schema.nullable
|
|
@@ -198,51 +213,30 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
198
213
|
schema.additionalProperties?.additionalProperties;
|
|
199
214
|
if (additionalProperties !== undefined) {
|
|
200
215
|
const type = schema.additionalProperties?.additionalProperties?.type;
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
style: { opacity: "0.6" },
|
|
215
|
-
children: ` (${format})`,
|
|
216
|
-
})
|
|
217
|
-
),
|
|
218
|
-
guard(getQualifierMessage(schema.additionalProperties), (message) =>
|
|
219
|
-
create("div", {
|
|
220
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
221
|
-
children: createDescription(message),
|
|
222
|
-
})
|
|
223
|
-
),
|
|
224
|
-
],
|
|
225
|
-
}),
|
|
216
|
+
const schemaName = getSchemaName(
|
|
217
|
+
schema.additionalProperties?.additionalProperties!
|
|
218
|
+
);
|
|
219
|
+
return create("SchemaItem", {
|
|
220
|
+
name: "property name*",
|
|
221
|
+
required: false,
|
|
222
|
+
schemaName: schemaName ?? type,
|
|
223
|
+
qualifierMessage:
|
|
224
|
+
schema.additionalProperties ??
|
|
225
|
+
getQualifierMessage(schema.additionalProperties),
|
|
226
|
+
schema: schema,
|
|
227
|
+
collapsible: false,
|
|
228
|
+
discriminator: false,
|
|
226
229
|
});
|
|
227
230
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
),
|
|
238
|
-
guard(getQualifierMessage(schema.additionalProperties), (message) =>
|
|
239
|
-
create("div", {
|
|
240
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
241
|
-
children: createDescription(message),
|
|
242
|
-
})
|
|
243
|
-
),
|
|
244
|
-
],
|
|
245
|
-
}),
|
|
231
|
+
const schemaName = getSchemaName(schema.additionalProperties!);
|
|
232
|
+
return create("SchemaItem", {
|
|
233
|
+
name: "property name*",
|
|
234
|
+
required: false,
|
|
235
|
+
schemaName: schemaName,
|
|
236
|
+
qualifierMessage: getQualifierMessage(schema),
|
|
237
|
+
schema: schema.additionalProperties,
|
|
238
|
+
collapsible: false,
|
|
239
|
+
discriminator: false,
|
|
246
240
|
});
|
|
247
241
|
}
|
|
248
242
|
return Object.entries(schema.additionalProperties!).map(([key, val]) =>
|
|
@@ -480,8 +474,8 @@ function createDetailsNode(
|
|
|
480
474
|
className: "openapi-schema__container",
|
|
481
475
|
children: [
|
|
482
476
|
create("strong", {
|
|
483
|
-
|
|
484
|
-
|
|
477
|
+
className: clsx("openapi-schema__property", {
|
|
478
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
485
479
|
}),
|
|
486
480
|
children: name,
|
|
487
481
|
}),
|
|
@@ -503,7 +497,7 @@ function createDetailsNode(
|
|
|
503
497
|
),
|
|
504
498
|
guard(nullable, () => [
|
|
505
499
|
create("span", {
|
|
506
|
-
className: "
|
|
500
|
+
className: "openapi-schema__nullable",
|
|
507
501
|
children: "nullable",
|
|
508
502
|
}),
|
|
509
503
|
]),
|
|
@@ -513,16 +507,14 @@ function createDetailsNode(
|
|
|
513
507
|
: required === true,
|
|
514
508
|
() => [
|
|
515
509
|
create("span", {
|
|
516
|
-
className:
|
|
517
|
-
"badge badge--danger openapi-schema__required",
|
|
510
|
+
className: "openapi-schema__required",
|
|
518
511
|
children: "required",
|
|
519
512
|
}),
|
|
520
513
|
]
|
|
521
514
|
),
|
|
522
515
|
guard(schema.deprecated, () => [
|
|
523
516
|
create("span", {
|
|
524
|
-
className:
|
|
525
|
-
"badge badge--warning openapi-schema__deprecated",
|
|
517
|
+
className: "openapi-schema__deprecated",
|
|
526
518
|
children: "deprecated",
|
|
527
519
|
}),
|
|
528
520
|
]),
|
|
@@ -574,14 +566,14 @@ function createPropertyDiscriminator(
|
|
|
574
566
|
}
|
|
575
567
|
|
|
576
568
|
return create("div", {
|
|
577
|
-
className: "openapi-discriminator__item",
|
|
569
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
578
570
|
children: create("div", {
|
|
579
571
|
children: [
|
|
580
572
|
create("span", {
|
|
581
573
|
className: "openapi-schema__container",
|
|
582
574
|
children: [
|
|
583
575
|
create("strong", {
|
|
584
|
-
className: "openapi-discriminator__name",
|
|
576
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
585
577
|
children: name,
|
|
586
578
|
}),
|
|
587
579
|
guard(schemaName, (name) =>
|
|
@@ -592,7 +584,7 @@ function createPropertyDiscriminator(
|
|
|
592
584
|
),
|
|
593
585
|
guard(required, () => [
|
|
594
586
|
create("span", {
|
|
595
|
-
className: "
|
|
587
|
+
className: "openapi-schema__required",
|
|
596
588
|
children: "required",
|
|
597
589
|
}),
|
|
598
590
|
]),
|
|
@@ -930,21 +922,21 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
930
922
|
value: `${title}`,
|
|
931
923
|
children: [
|
|
932
924
|
createDetails({
|
|
933
|
-
className: "openapi-markdown__details",
|
|
925
|
+
className: "openapi-markdown__details response",
|
|
934
926
|
"data-collapsed": false,
|
|
935
927
|
open: true,
|
|
936
928
|
...rest,
|
|
937
929
|
children: [
|
|
938
930
|
createDetailsSummary({
|
|
939
|
-
|
|
931
|
+
className:
|
|
932
|
+
"openapi-markdown__details-summary-response",
|
|
940
933
|
children: [
|
|
941
934
|
create("strong", { children: `${title}` }),
|
|
942
935
|
guard(
|
|
943
936
|
body.required && body.required === true,
|
|
944
937
|
() => [
|
|
945
938
|
create("span", {
|
|
946
|
-
className:
|
|
947
|
-
"badge badge--danger openapi-schema__required",
|
|
939
|
+
className: "openapi-schema__required",
|
|
948
940
|
children: "required",
|
|
949
941
|
}),
|
|
950
942
|
]
|
package/src/markdown/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { createLogo } from "./createLogo";
|
|
|
24
24
|
import { createMethodEndpoint } from "./createMethodEndpoint";
|
|
25
25
|
import { createParamsDetails } from "./createParamsDetails";
|
|
26
26
|
import { createRequestBodyDetails } from "./createRequestBodyDetails";
|
|
27
|
+
import { createRequestHeader } from "./createRequestHeader";
|
|
27
28
|
import { createStatusCodes } from "./createStatusCodes";
|
|
28
29
|
import { createTermsOfService } from "./createTermsOfService";
|
|
29
30
|
import { createVendorExtensions } from "./createVendorExtensions";
|
|
@@ -70,17 +71,17 @@ export function createApiPageMD({
|
|
|
70
71
|
`import TabItem from "@theme/TabItem";\n\n`,
|
|
71
72
|
createHeading(title.replace(lessThan, "<").replace(greaterThan, ">")),
|
|
72
73
|
createMethodEndpoint(method, path),
|
|
73
|
-
`## ${title.replace(lessThan, "<").replace(greaterThan, ">")}\n\n`,
|
|
74
74
|
infoPath && createAuthorization(infoPath),
|
|
75
75
|
frontMatter.show_extensions && createVendorExtensions(extensions),
|
|
76
76
|
createDeprecationNotice({ deprecated, description: deprecatedDescription }),
|
|
77
77
|
createDescription(description),
|
|
78
|
+
createRequestHeader("Request"),
|
|
78
79
|
createParamsDetails({ parameters, type: "path" }),
|
|
79
80
|
createParamsDetails({ parameters, type: "query" }),
|
|
80
81
|
createParamsDetails({ parameters, type: "header" }),
|
|
81
82
|
createParamsDetails({ parameters, type: "cookie" }),
|
|
82
83
|
createRequestBodyDetails({
|
|
83
|
-
title: "
|
|
84
|
+
title: "Body",
|
|
84
85
|
body: requestBody,
|
|
85
86
|
} as Props),
|
|
86
87
|
createStatusCodes({ responses }),
|