docusaurus-plugin-openapi-docs 1.5.1-hotfix1 → 1.5.2
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/LICENSE +21 -0
- package/lib/markdown/createArrayBracket.d.ts +2 -0
- package/lib/markdown/createArrayBracket.js +37 -0
- package/lib/markdown/createRequestSchema.js +119 -79
- package/lib/markdown/createResponseSchema.js +123 -82
- package/lib/markdown/createStatusCodes.js +4 -6
- package/lib/openapi/createRequestExample.js +26 -7
- package/lib/openapi/createResponseExample.js +26 -7
- package/lib/openapi/utils/loadAndResolveSpec.js +1 -1
- package/package.json +4 -3
- package/src/markdown/createArrayBracket.ts +35 -0
- package/src/markdown/createRequestSchema.ts +136 -95
- package/src/markdown/createResponseSchema.ts +143 -98
- package/src/markdown/createStatusCodes.ts +4 -8
- package/src/openapi/createRequestExample.ts +35 -12
- package/src/openapi/createResponseExample.ts +35 -12
- package/src/openapi/utils/loadAndResolveSpec.ts +1 -1
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createResponseSchema = exports.mergeAllOf = void 0;
|
|
10
|
+
const createArrayBracket_1 = require("./createArrayBracket");
|
|
10
11
|
const createDescription_1 = require("./createDescription");
|
|
11
12
|
const createDetails_1 = require("./createDetails");
|
|
12
13
|
const createDetailsSummary_1 = require("./createDetailsSummary");
|
|
@@ -47,46 +48,55 @@ exports.mergeAllOf = mergeAllOf;
|
|
|
47
48
|
*/
|
|
48
49
|
function createAnyOneOf(schema) {
|
|
49
50
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
50
|
-
return (0, utils_1.create)("
|
|
51
|
+
return (0, utils_1.create)("li", {
|
|
51
52
|
children: [
|
|
52
|
-
(0, utils_1.create)("
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
53
|
+
(0, utils_1.create)("span", {
|
|
54
|
+
className: "badge badge--info",
|
|
55
|
+
children: type,
|
|
56
|
+
}),
|
|
57
|
+
(0, utils_1.create)("SchemaTabs", {
|
|
58
|
+
children: schema[type].map((anyOneSchema, index) => {
|
|
59
|
+
const label = anyOneSchema.title
|
|
60
|
+
? anyOneSchema.title
|
|
61
|
+
: `MOD${index + 1}`;
|
|
62
|
+
const anyOneChildren = [];
|
|
63
|
+
if (anyOneSchema.properties !== undefined) {
|
|
64
|
+
anyOneChildren.push(createProperties(anyOneSchema));
|
|
65
|
+
}
|
|
66
|
+
if (anyOneSchema.allOf !== undefined) {
|
|
67
|
+
anyOneChildren.push(createNodes(anyOneSchema));
|
|
68
|
+
}
|
|
69
|
+
if (anyOneSchema.items !== undefined) {
|
|
70
|
+
anyOneChildren.push(createItems(anyOneSchema));
|
|
71
|
+
}
|
|
72
|
+
if (anyOneSchema.type === "string" ||
|
|
73
|
+
anyOneSchema.type === "number" ||
|
|
74
|
+
anyOneSchema.type === "integer" ||
|
|
75
|
+
anyOneSchema.type === "boolean") {
|
|
76
|
+
anyOneChildren.push(createNodes(anyOneSchema));
|
|
77
|
+
}
|
|
78
|
+
if (anyOneChildren.length) {
|
|
79
|
+
if (schema.type === "array") {
|
|
80
|
+
return (0, utils_1.create)("TabItem", {
|
|
81
|
+
label: label,
|
|
82
|
+
value: `${index}-item-properties`,
|
|
83
|
+
children: [
|
|
84
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
85
|
+
anyOneChildren,
|
|
86
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
87
|
+
]
|
|
88
|
+
.filter(Boolean)
|
|
89
|
+
.flat(),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return (0, utils_1.create)("TabItem", {
|
|
93
|
+
label: label,
|
|
94
|
+
value: `${index}-item-properties`,
|
|
95
|
+
children: anyOneChildren,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}),
|
|
90
100
|
}),
|
|
91
101
|
],
|
|
92
102
|
});
|
|
@@ -189,15 +199,27 @@ function createAdditionalProperties(schema) {
|
|
|
189
199
|
}
|
|
190
200
|
// TODO: figure out how to handle array of objects
|
|
191
201
|
function createItems(schema) {
|
|
192
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
202
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
193
203
|
if (((_a = schema.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
|
|
194
|
-
return
|
|
204
|
+
return [
|
|
205
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
206
|
+
createProperties(schema.items),
|
|
207
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
208
|
+
].flat();
|
|
195
209
|
}
|
|
196
210
|
if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.additionalProperties) !== undefined) {
|
|
197
|
-
return
|
|
211
|
+
return [
|
|
212
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
213
|
+
createAdditionalProperties(schema.items),
|
|
214
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
215
|
+
].flat();
|
|
198
216
|
}
|
|
199
217
|
if (((_c = schema.items) === null || _c === void 0 ? void 0 : _c.oneOf) !== undefined || ((_d = schema.items) === null || _d === void 0 ? void 0 : _d.anyOf) !== undefined) {
|
|
200
|
-
return
|
|
218
|
+
return [
|
|
219
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
220
|
+
createAnyOneOf(schema.items),
|
|
221
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
222
|
+
].flat();
|
|
201
223
|
}
|
|
202
224
|
if (((_e = schema.items) === null || _e === void 0 ? void 0 : _e.allOf) !== undefined) {
|
|
203
225
|
// TODO: figure out if and how we should pass merged required array
|
|
@@ -206,41 +228,54 @@ function createItems(schema) {
|
|
|
206
228
|
if ((mergedSchemas.oneOf !== undefined ||
|
|
207
229
|
mergedSchemas.anyOf !== undefined) &&
|
|
208
230
|
mergedSchemas.properties) {
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
231
|
+
return [
|
|
232
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
233
|
+
createAnyOneOf(mergedSchemas),
|
|
234
|
+
createProperties(mergedSchemas),
|
|
235
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
236
|
+
].flat();
|
|
215
237
|
}
|
|
216
238
|
// Handles only anyOf/oneOf
|
|
217
239
|
if (mergedSchemas.oneOf !== undefined ||
|
|
218
240
|
mergedSchemas.anyOf !== undefined) {
|
|
219
|
-
return
|
|
220
|
-
|
|
221
|
-
|
|
241
|
+
return [
|
|
242
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
243
|
+
createAnyOneOf(mergedSchemas),
|
|
244
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
245
|
+
].flat();
|
|
222
246
|
}
|
|
223
247
|
// Handles properties
|
|
224
248
|
if (mergedSchemas.properties !== undefined) {
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
|
|
249
|
+
return [
|
|
250
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
251
|
+
createProperties(mergedSchemas),
|
|
252
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
253
|
+
].flat();
|
|
228
254
|
}
|
|
229
255
|
}
|
|
230
256
|
if (((_g = schema.items) === null || _g === void 0 ? void 0 : _g.type) === "string" ||
|
|
231
257
|
((_h = schema.items) === null || _h === void 0 ? void 0 : _h.type) === "number" ||
|
|
232
258
|
((_j = schema.items) === null || _j === void 0 ? void 0 : _j.type) === "integer" ||
|
|
233
|
-
((_k = schema.items) === null || _k === void 0 ? void 0 : _k.type) === "boolean"
|
|
234
|
-
|
|
259
|
+
((_k = schema.items) === null || _k === void 0 ? void 0 : _k.type) === "boolean" ||
|
|
260
|
+
((_l = schema.items) === null || _l === void 0 ? void 0 : _l.type) === "object") {
|
|
261
|
+
return [
|
|
262
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
263
|
+
createNodes(schema.items),
|
|
264
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
265
|
+
].flat();
|
|
235
266
|
}
|
|
236
267
|
// TODO: clean this up or eliminate it?
|
|
237
|
-
return
|
|
238
|
-
|
|
239
|
-
schema
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
:
|
|
243
|
-
|
|
268
|
+
return [
|
|
269
|
+
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
270
|
+
Object.entries(schema.items).map(([key, val]) => createEdges({
|
|
271
|
+
name: key,
|
|
272
|
+
schema: val,
|
|
273
|
+
required: Array.isArray(schema.required)
|
|
274
|
+
? schema.required.includes(key)
|
|
275
|
+
: false,
|
|
276
|
+
})),
|
|
277
|
+
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
278
|
+
].flat();
|
|
244
279
|
}
|
|
245
280
|
/**
|
|
246
281
|
* For handling discriminators that do not map to a same-level property
|
|
@@ -353,6 +388,15 @@ function createDetailsNode(name, schemaName, schema, required) {
|
|
|
353
388
|
style: { opacity: "0.6" },
|
|
354
389
|
children: ` ${schemaName}`,
|
|
355
390
|
}),
|
|
391
|
+
(0, utils_1.guard)(schema.nullable && schema.nullable === true, () => [
|
|
392
|
+
(0, utils_1.create)("strong", {
|
|
393
|
+
style: {
|
|
394
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
395
|
+
color: "var(--openapi-nullable)",
|
|
396
|
+
},
|
|
397
|
+
children: " nullable",
|
|
398
|
+
}),
|
|
399
|
+
]),
|
|
356
400
|
(0, utils_1.guard)(schema.required && schema.required === true, () => [
|
|
357
401
|
(0, utils_1.create)("strong", {
|
|
358
402
|
style: {
|
|
@@ -479,11 +523,9 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
479
523
|
collapsible: false,
|
|
480
524
|
name,
|
|
481
525
|
required: false,
|
|
482
|
-
deprecated: mergedSchemas.deprecated,
|
|
483
|
-
schemaDescription: mergedSchemas.description,
|
|
484
526
|
schemaName: schemaName,
|
|
485
527
|
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
486
|
-
|
|
528
|
+
schema: mergedSchemas,
|
|
487
529
|
});
|
|
488
530
|
}
|
|
489
531
|
if (schema.properties !== undefined) {
|
|
@@ -507,40 +549,43 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
507
549
|
collapsible: false,
|
|
508
550
|
name,
|
|
509
551
|
required: false,
|
|
510
|
-
deprecated: schema.deprecated,
|
|
511
|
-
schemaDescription: schema.description,
|
|
512
552
|
schemaName: schemaName,
|
|
513
553
|
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
514
|
-
|
|
554
|
+
schema: schema,
|
|
515
555
|
});
|
|
516
556
|
}
|
|
517
557
|
/**
|
|
518
558
|
* Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
|
|
519
559
|
*/
|
|
520
560
|
function createNodes(schema) {
|
|
561
|
+
const nodes = [];
|
|
521
562
|
// if (schema.discriminator !== undefined) {
|
|
522
563
|
// return createDiscriminator(schema);
|
|
523
564
|
// }
|
|
524
565
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
525
|
-
|
|
566
|
+
nodes.push(createAnyOneOf(schema));
|
|
526
567
|
}
|
|
527
568
|
if (schema.allOf !== undefined) {
|
|
528
569
|
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
529
|
-
// allOf seems to always result in properties
|
|
530
570
|
if (mergedSchemas.properties !== undefined) {
|
|
531
|
-
|
|
571
|
+
nodes.push(createProperties(mergedSchemas));
|
|
572
|
+
}
|
|
573
|
+
if (mergedSchemas.items !== undefined) {
|
|
574
|
+
nodes.push(createItems(mergedSchemas));
|
|
532
575
|
}
|
|
533
576
|
}
|
|
534
577
|
if (schema.properties !== undefined) {
|
|
535
|
-
|
|
578
|
+
nodes.push(createProperties(schema));
|
|
536
579
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return createAdditionalProperties(schema);
|
|
580
|
+
if (schema.additionalProperties !== undefined) {
|
|
581
|
+
nodes.push(createAdditionalProperties(schema));
|
|
540
582
|
}
|
|
541
583
|
// TODO: figure out how to handle array of objects
|
|
542
584
|
if (schema.items !== undefined) {
|
|
543
|
-
|
|
585
|
+
nodes.push(createItems(schema));
|
|
586
|
+
}
|
|
587
|
+
if (nodes.length && nodes.length > 0) {
|
|
588
|
+
return nodes.filter(Boolean).flat();
|
|
544
589
|
}
|
|
545
590
|
// primitive
|
|
546
591
|
if (schema.type !== undefined) {
|
|
@@ -616,10 +661,6 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
616
661
|
style: { textAlign: "left" },
|
|
617
662
|
children: [
|
|
618
663
|
(0, utils_1.create)("strong", { children: `${title}` }),
|
|
619
|
-
(0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
|
|
620
|
-
style: { opacity: "0.6" },
|
|
621
|
-
children: ` array`,
|
|
622
|
-
})),
|
|
623
664
|
(0, utils_1.guard)(body.required && body.required === true, () => [
|
|
624
665
|
(0, utils_1.create)("strong", {
|
|
625
666
|
style: {
|
|
@@ -110,12 +110,10 @@ function createResponseExamples(responseExamples, mimeType) {
|
|
|
110
110
|
language = "xml";
|
|
111
111
|
}
|
|
112
112
|
return Object.entries(responseExamples).map(([exampleName, exampleValue]) => {
|
|
113
|
-
const camelToSpaceName = exampleName.replace(/([A-Z])/g, " $1");
|
|
114
|
-
let finalFormattedName = camelToSpaceName.charAt(0).toUpperCase() + camelToSpaceName.slice(1);
|
|
115
113
|
if (typeof exampleValue.value === "object") {
|
|
116
114
|
return (0, utils_1.create)("TabItem", {
|
|
117
|
-
label: `${
|
|
118
|
-
value: `${
|
|
115
|
+
label: `${exampleName}`,
|
|
116
|
+
value: `${exampleName}`,
|
|
119
117
|
children: [
|
|
120
118
|
(0, utils_2.guard)(exampleValue.summary, (summary) => [
|
|
121
119
|
(0, utils_1.create)("p", {
|
|
@@ -130,8 +128,8 @@ function createResponseExamples(responseExamples, mimeType) {
|
|
|
130
128
|
});
|
|
131
129
|
}
|
|
132
130
|
return (0, utils_1.create)("TabItem", {
|
|
133
|
-
label: `${
|
|
134
|
-
value: `${
|
|
131
|
+
label: `${exampleName}`,
|
|
132
|
+
value: `${exampleName}`,
|
|
135
133
|
children: [
|
|
136
134
|
(0, utils_2.guard)(exampleValue.summary, (summary) => [
|
|
137
135
|
(0, utils_1.create)("p", {
|
|
@@ -11,6 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.sampleRequestFromSchema = void 0;
|
|
13
13
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
14
15
|
const createRequestSchema_1 = require("../markdown/createRequestSchema");
|
|
15
16
|
const primitives = {
|
|
16
17
|
string: {
|
|
@@ -60,15 +61,27 @@ function sampleRequestFromProp(name, prop, obj) {
|
|
|
60
61
|
}
|
|
61
62
|
const sampleRequestFromSchema = (schema = {}) => {
|
|
62
63
|
try {
|
|
63
|
-
|
|
64
|
+
// deep copy schema before processing
|
|
65
|
+
let schemaCopy = JSON.parse(JSON.stringify(schema));
|
|
66
|
+
let { type, example, allOf, properties, items, oneOf, anyOf } = schemaCopy;
|
|
64
67
|
if (example !== undefined) {
|
|
65
68
|
return example;
|
|
66
69
|
}
|
|
67
70
|
if (oneOf) {
|
|
71
|
+
if (properties) {
|
|
72
|
+
const combinedSchemas = (0, merge_1.default)(schemaCopy, oneOf[0]);
|
|
73
|
+
delete combinedSchemas.oneOf;
|
|
74
|
+
return (0, exports.sampleRequestFromSchema)(combinedSchemas);
|
|
75
|
+
}
|
|
68
76
|
// Just go with first schema
|
|
69
77
|
return (0, exports.sampleRequestFromSchema)(oneOf[0]);
|
|
70
78
|
}
|
|
71
79
|
if (anyOf) {
|
|
80
|
+
if (properties) {
|
|
81
|
+
const combinedSchemas = (0, merge_1.default)(schemaCopy, anyOf[0]);
|
|
82
|
+
delete combinedSchemas.anyOf;
|
|
83
|
+
return (0, exports.sampleRequestFromSchema)(combinedSchemas);
|
|
84
|
+
}
|
|
72
85
|
// Just go with first schema
|
|
73
86
|
return (0, exports.sampleRequestFromSchema)(anyOf[0]);
|
|
74
87
|
}
|
|
@@ -81,6 +94,11 @@ const sampleRequestFromSchema = (schema = {}) => {
|
|
|
81
94
|
}
|
|
82
95
|
}
|
|
83
96
|
}
|
|
97
|
+
if (properties) {
|
|
98
|
+
const combinedSchemas = (0, merge_1.default)(schemaCopy, mergedSchemas);
|
|
99
|
+
delete combinedSchemas.allOf;
|
|
100
|
+
return (0, exports.sampleRequestFromSchema)(combinedSchemas);
|
|
101
|
+
}
|
|
84
102
|
return (0, exports.sampleRequestFromSchema)(mergedSchemas);
|
|
85
103
|
}
|
|
86
104
|
if (!type) {
|
|
@@ -133,16 +151,17 @@ const sampleRequestFromSchema = (schema = {}) => {
|
|
|
133
151
|
}
|
|
134
152
|
return [(0, exports.sampleRequestFromSchema)(items)];
|
|
135
153
|
}
|
|
136
|
-
if (
|
|
137
|
-
if (
|
|
138
|
-
return
|
|
154
|
+
if (schemaCopy.enum) {
|
|
155
|
+
if (schemaCopy.default) {
|
|
156
|
+
return schemaCopy.default;
|
|
139
157
|
}
|
|
140
|
-
return normalizeArray(
|
|
158
|
+
return normalizeArray(schemaCopy.enum)[0];
|
|
141
159
|
}
|
|
142
|
-
if ((schema.readOnly && schema.readOnly === true) ||
|
|
160
|
+
if ((schema.readOnly && schema.readOnly === true) ||
|
|
161
|
+
schemaCopy.deprecated) {
|
|
143
162
|
return undefined;
|
|
144
163
|
}
|
|
145
|
-
return primitive(
|
|
164
|
+
return primitive(schemaCopy);
|
|
146
165
|
}
|
|
147
166
|
catch (err) {
|
|
148
167
|
console.error(chalk_1.default.yellow("WARNING: failed to create example from schema object:", err));
|
|
@@ -11,6 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.sampleResponseFromSchema = void 0;
|
|
13
13
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
14
15
|
const createResponseSchema_1 = require("../markdown/createResponseSchema");
|
|
15
16
|
const primitives = {
|
|
16
17
|
string: {
|
|
@@ -60,7 +61,9 @@ function sampleResponseFromProp(name, prop, obj) {
|
|
|
60
61
|
}
|
|
61
62
|
const sampleResponseFromSchema = (schema = {}) => {
|
|
62
63
|
try {
|
|
63
|
-
|
|
64
|
+
// deep copy schema before processing
|
|
65
|
+
let schemaCopy = JSON.parse(JSON.stringify(schema));
|
|
66
|
+
let { type, example, allOf, properties, items, oneOf, anyOf } = schemaCopy;
|
|
64
67
|
if (example !== undefined) {
|
|
65
68
|
return example;
|
|
66
69
|
}
|
|
@@ -74,13 +77,28 @@ const sampleResponseFromSchema = (schema = {}) => {
|
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
}
|
|
80
|
+
if (properties) {
|
|
81
|
+
const combinedSchemas = (0, merge_1.default)(schemaCopy, mergedSchemas);
|
|
82
|
+
delete combinedSchemas.allOf;
|
|
83
|
+
return (0, exports.sampleResponseFromSchema)(combinedSchemas);
|
|
84
|
+
}
|
|
77
85
|
return (0, exports.sampleResponseFromSchema)(mergedSchemas);
|
|
78
86
|
}
|
|
79
87
|
if (oneOf) {
|
|
88
|
+
if (properties) {
|
|
89
|
+
const combinedSchemas = (0, merge_1.default)(schemaCopy, oneOf[0]);
|
|
90
|
+
delete combinedSchemas.oneOf;
|
|
91
|
+
return (0, exports.sampleResponseFromSchema)(combinedSchemas);
|
|
92
|
+
}
|
|
80
93
|
// Just go with first schema
|
|
81
94
|
return (0, exports.sampleResponseFromSchema)(oneOf[0]);
|
|
82
95
|
}
|
|
83
96
|
if (anyOf) {
|
|
97
|
+
if (properties) {
|
|
98
|
+
const combinedSchemas = (0, merge_1.default)(schemaCopy, anyOf[0]);
|
|
99
|
+
delete combinedSchemas.anyOf;
|
|
100
|
+
return (0, exports.sampleResponseFromSchema)(combinedSchemas);
|
|
101
|
+
}
|
|
84
102
|
// Just go with first schema
|
|
85
103
|
return (0, exports.sampleResponseFromSchema)(anyOf[0]);
|
|
86
104
|
}
|
|
@@ -134,16 +152,17 @@ const sampleResponseFromSchema = (schema = {}) => {
|
|
|
134
152
|
}
|
|
135
153
|
return [(0, exports.sampleResponseFromSchema)(items)];
|
|
136
154
|
}
|
|
137
|
-
if (
|
|
138
|
-
if (
|
|
139
|
-
return
|
|
155
|
+
if (schemaCopy.enum) {
|
|
156
|
+
if (schemaCopy.default) {
|
|
157
|
+
return schemaCopy.default;
|
|
140
158
|
}
|
|
141
|
-
return normalizeArray(
|
|
159
|
+
return normalizeArray(schemaCopy.enum)[0];
|
|
142
160
|
}
|
|
143
|
-
if ((
|
|
161
|
+
if ((schemaCopy.writeOnly && schemaCopy.writeOnly === true) ||
|
|
162
|
+
schemaCopy.deprecated) {
|
|
144
163
|
return undefined;
|
|
145
164
|
}
|
|
146
|
-
return primitive(
|
|
165
|
+
return primitive(schemaCopy);
|
|
147
166
|
}
|
|
148
167
|
catch (err) {
|
|
149
168
|
console.error(chalk_1.default.yellow("WARNING: failed to create example from schema object:", err));
|
|
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.loadAndResolveSpec = exports.convertSwagger2OpenAPI = void 0;
|
|
13
|
-
const json_schema_ref_parser_1 = __importDefault(require("@
|
|
13
|
+
const json_schema_ref_parser_1 = __importDefault(require("@apidevtools/json-schema-ref-parser"));
|
|
14
14
|
const openapi_core_1 = require("@redocly/openapi-core");
|
|
15
15
|
const chalk_1 = __importDefault(require("chalk"));
|
|
16
16
|
// @ts-ignore
|
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.5.
|
|
4
|
+
"version": "1.5.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"utility-types": "^3.10.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@
|
|
42
|
+
"@apidevtools/json-schema-ref-parser": "^9.0.9",
|
|
43
43
|
"@docusaurus/mdx-loader": "^2.0.1",
|
|
44
44
|
"@docusaurus/plugin-content-docs": "^2.0.1",
|
|
45
45
|
"@docusaurus/utils": "^2.0.1",
|
|
@@ -67,5 +67,6 @@
|
|
|
67
67
|
},
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "fa3096190356c0161a8e255b9950857a7b131eef"
|
|
71
72
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import { create } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createOpeningArrayBracket() {
|
|
11
|
+
return create("li", {
|
|
12
|
+
children: create("div", {
|
|
13
|
+
style: {
|
|
14
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
15
|
+
opacity: "0.6",
|
|
16
|
+
marginLeft: "-.5rem",
|
|
17
|
+
paddingBottom: ".5rem",
|
|
18
|
+
},
|
|
19
|
+
children: ["Array ["],
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createClosingArrayBracket() {
|
|
25
|
+
return create("li", {
|
|
26
|
+
children: create("div", {
|
|
27
|
+
style: {
|
|
28
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
29
|
+
opacity: "0.6",
|
|
30
|
+
marginLeft: "-.5rem",
|
|
31
|
+
},
|
|
32
|
+
children: ["]"],
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
}
|