docusaurus-plugin-openapi-docs 1.5.1 → 1.6.0
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/index.js +5 -0
- package/lib/markdown/createArrayBracket.d.ts +2 -0
- package/lib/markdown/createArrayBracket.js +37 -0
- package/lib/markdown/createAuthentication.js +45 -13
- package/lib/markdown/createRequestSchema.js +133 -91
- package/lib/markdown/createResponseSchema.js +140 -95
- package/lib/markdown/createStatusCodes.js +7 -7
- package/lib/markdown/index.js +1 -1
- package/lib/openapi/createRequestExample.js +27 -8
- package/lib/openapi/createResponseExample.js +27 -8
- package/lib/openapi/openapi.js +7 -1
- package/lib/openapi/utils/loadAndResolveSpec.js +13 -0
- package/lib/options.js +1 -0
- 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/createArrayBracket.ts +35 -0
- package/src/markdown/createAuthentication.ts +53 -17
- package/src/markdown/createRequestSchema.ts +208 -107
- package/src/markdown/createResponseSchema.ts +228 -119
- package/src/markdown/createStatusCodes.ts +42 -47
- package/src/markdown/index.ts +1 -1
- package/src/openapi/createRequestExample.ts +36 -13
- package/src/openapi/createResponseExample.ts +36 -13
- package/src/openapi/openapi.ts +7 -1
- package/src/openapi/utils/loadAndResolveSpec.ts +15 -0
- package/src/options.ts +1 -0
- package/src/sidebars/index.ts +6 -1
- package/src/types.ts +1 -0
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
8
|
import { MediaTypeObject, SchemaObject } from "../openapi/types";
|
|
9
|
+
import {
|
|
10
|
+
createClosingArrayBracket,
|
|
11
|
+
createOpeningArrayBracket,
|
|
12
|
+
} from "./createArrayBracket";
|
|
9
13
|
import { createDescription } from "./createDescription";
|
|
10
14
|
import { createDetails } from "./createDetails";
|
|
11
15
|
import { createDetailsSummary } from "./createDetailsSummary";
|
|
@@ -54,54 +58,63 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
54
58
|
*/
|
|
55
59
|
function createAnyOneOf(schema: SchemaObject): any {
|
|
56
60
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
57
|
-
return create("
|
|
61
|
+
return create("li", {
|
|
58
62
|
children: [
|
|
59
|
-
create("
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
63
|
+
create("span", {
|
|
64
|
+
className: "badge badge--info",
|
|
65
|
+
children: type,
|
|
66
|
+
}),
|
|
67
|
+
create("SchemaTabs", {
|
|
68
|
+
children: schema[type]!.map((anyOneSchema, index) => {
|
|
69
|
+
const label = anyOneSchema.title
|
|
70
|
+
? anyOneSchema.title
|
|
71
|
+
: `MOD${index + 1}`;
|
|
72
|
+
const anyOneChildren = [];
|
|
73
|
+
|
|
74
|
+
if (anyOneSchema.properties !== undefined) {
|
|
75
|
+
anyOneChildren.push(createProperties(anyOneSchema));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (anyOneSchema.allOf !== undefined) {
|
|
79
|
+
anyOneChildren.push(createNodes(anyOneSchema));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (anyOneSchema.items !== undefined) {
|
|
83
|
+
anyOneChildren.push(createItems(anyOneSchema));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
anyOneSchema.type === "string" ||
|
|
88
|
+
anyOneSchema.type === "number" ||
|
|
89
|
+
anyOneSchema.type === "integer" ||
|
|
90
|
+
anyOneSchema.type === "boolean"
|
|
91
|
+
) {
|
|
92
|
+
anyOneChildren.push(createNodes(anyOneSchema));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (anyOneChildren.length) {
|
|
96
|
+
if (schema.type === "array") {
|
|
97
|
+
return create("TabItem", {
|
|
98
|
+
label: label,
|
|
99
|
+
value: `${index}-item-properties`,
|
|
100
|
+
children: [
|
|
101
|
+
createOpeningArrayBracket(),
|
|
102
|
+
anyOneChildren,
|
|
103
|
+
createClosingArrayBracket(),
|
|
104
|
+
]
|
|
105
|
+
.filter(Boolean)
|
|
106
|
+
.flat(),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return create("TabItem", {
|
|
110
|
+
label: label,
|
|
111
|
+
value: `${index}-item-properties`,
|
|
112
|
+
children: anyOneChildren,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return undefined;
|
|
117
|
+
}),
|
|
105
118
|
}),
|
|
106
119
|
],
|
|
107
120
|
});
|
|
@@ -152,11 +165,11 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
152
165
|
// }
|
|
153
166
|
|
|
154
167
|
if (
|
|
155
|
-
schema.additionalProperties?.type === "string" ||
|
|
156
|
-
schema.additionalProperties?.type === "object" ||
|
|
157
|
-
schema.additionalProperties?.type === "boolean" ||
|
|
158
|
-
schema.additionalProperties?.type === "integer" ||
|
|
159
|
-
schema.additionalProperties?.type === "number"
|
|
168
|
+
(schema.additionalProperties?.type as string) === "string" ||
|
|
169
|
+
(schema.additionalProperties?.type as string) === "object" ||
|
|
170
|
+
(schema.additionalProperties?.type as string) === "boolean" ||
|
|
171
|
+
(schema.additionalProperties?.type as string) === "integer" ||
|
|
172
|
+
(schema.additionalProperties?.type as string) === "number"
|
|
160
173
|
) {
|
|
161
174
|
const type = schema.additionalProperties?.type;
|
|
162
175
|
const additionalProperties =
|
|
@@ -224,15 +237,27 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
224
237
|
// TODO: figure out how to handle array of objects
|
|
225
238
|
function createItems(schema: SchemaObject) {
|
|
226
239
|
if (schema.items?.properties !== undefined) {
|
|
227
|
-
return
|
|
240
|
+
return [
|
|
241
|
+
createOpeningArrayBracket(),
|
|
242
|
+
createProperties(schema.items),
|
|
243
|
+
createClosingArrayBracket(),
|
|
244
|
+
].flat();
|
|
228
245
|
}
|
|
229
246
|
|
|
230
247
|
if (schema.items?.additionalProperties !== undefined) {
|
|
231
|
-
return
|
|
248
|
+
return [
|
|
249
|
+
createOpeningArrayBracket(),
|
|
250
|
+
createAdditionalProperties(schema.items),
|
|
251
|
+
createClosingArrayBracket(),
|
|
252
|
+
].flat();
|
|
232
253
|
}
|
|
233
254
|
|
|
234
255
|
if (schema.items?.oneOf !== undefined || schema.items?.anyOf !== undefined) {
|
|
235
|
-
return
|
|
256
|
+
return [
|
|
257
|
+
createOpeningArrayBracket(),
|
|
258
|
+
createAnyOneOf(schema.items!),
|
|
259
|
+
createClosingArrayBracket(),
|
|
260
|
+
].flat();
|
|
236
261
|
}
|
|
237
262
|
|
|
238
263
|
if (schema.items?.allOf !== undefined) {
|
|
@@ -249,12 +274,12 @@ function createItems(schema: SchemaObject) {
|
|
|
249
274
|
mergedSchemas.anyOf !== undefined) &&
|
|
250
275
|
mergedSchemas.properties
|
|
251
276
|
) {
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
277
|
+
return [
|
|
278
|
+
createOpeningArrayBracket(),
|
|
279
|
+
createAnyOneOf(mergedSchemas),
|
|
280
|
+
createProperties(mergedSchemas),
|
|
281
|
+
createClosingArrayBracket(),
|
|
282
|
+
].flat();
|
|
258
283
|
}
|
|
259
284
|
|
|
260
285
|
// Handles only anyOf/oneOf
|
|
@@ -262,16 +287,20 @@ function createItems(schema: SchemaObject) {
|
|
|
262
287
|
mergedSchemas.oneOf !== undefined ||
|
|
263
288
|
mergedSchemas.anyOf !== undefined
|
|
264
289
|
) {
|
|
265
|
-
return
|
|
266
|
-
|
|
267
|
-
|
|
290
|
+
return [
|
|
291
|
+
createOpeningArrayBracket(),
|
|
292
|
+
createAnyOneOf(mergedSchemas),
|
|
293
|
+
createClosingArrayBracket(),
|
|
294
|
+
].flat();
|
|
268
295
|
}
|
|
269
296
|
|
|
270
297
|
// Handles properties
|
|
271
298
|
if (mergedSchemas.properties !== undefined) {
|
|
272
|
-
return
|
|
273
|
-
|
|
274
|
-
|
|
299
|
+
return [
|
|
300
|
+
createOpeningArrayBracket(),
|
|
301
|
+
createProperties(mergedSchemas),
|
|
302
|
+
createClosingArrayBracket(),
|
|
303
|
+
].flat();
|
|
275
304
|
}
|
|
276
305
|
}
|
|
277
306
|
|
|
@@ -279,21 +308,30 @@ function createItems(schema: SchemaObject) {
|
|
|
279
308
|
schema.items?.type === "string" ||
|
|
280
309
|
schema.items?.type === "number" ||
|
|
281
310
|
schema.items?.type === "integer" ||
|
|
282
|
-
schema.items?.type === "boolean"
|
|
311
|
+
schema.items?.type === "boolean" ||
|
|
312
|
+
schema.items?.type === "object"
|
|
283
313
|
) {
|
|
284
|
-
return
|
|
314
|
+
return [
|
|
315
|
+
createOpeningArrayBracket(),
|
|
316
|
+
createNodes(schema.items),
|
|
317
|
+
createClosingArrayBracket(),
|
|
318
|
+
].flat();
|
|
285
319
|
}
|
|
286
320
|
|
|
287
321
|
// TODO: clean this up or eliminate it?
|
|
288
|
-
return
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
:
|
|
295
|
-
|
|
296
|
-
|
|
322
|
+
return [
|
|
323
|
+
createOpeningArrayBracket(),
|
|
324
|
+
Object.entries(schema.items!).map(([key, val]) =>
|
|
325
|
+
createEdges({
|
|
326
|
+
name: key,
|
|
327
|
+
schema: val,
|
|
328
|
+
required: Array.isArray(schema.required)
|
|
329
|
+
? schema.required.includes(key)
|
|
330
|
+
: false,
|
|
331
|
+
})
|
|
332
|
+
),
|
|
333
|
+
createClosingArrayBracket(),
|
|
334
|
+
].flat();
|
|
297
335
|
}
|
|
298
336
|
|
|
299
337
|
/**
|
|
@@ -404,7 +442,8 @@ function createDetailsNode(
|
|
|
404
442
|
name: string,
|
|
405
443
|
schemaName: string,
|
|
406
444
|
schema: SchemaObject,
|
|
407
|
-
required: string[] | boolean
|
|
445
|
+
required: string[] | boolean,
|
|
446
|
+
nullable: boolean | unknown
|
|
408
447
|
): any {
|
|
409
448
|
return create("SchemaItem", {
|
|
410
449
|
collapsible: true,
|
|
@@ -419,15 +458,33 @@ function createDetailsNode(
|
|
|
419
458
|
style: { opacity: "0.6" },
|
|
420
459
|
children: ` ${schemaName}`,
|
|
421
460
|
}),
|
|
422
|
-
guard(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
461
|
+
guard(
|
|
462
|
+
(schema.nullable && schema.nullable === true) ||
|
|
463
|
+
(nullable && nullable === true),
|
|
464
|
+
() => [
|
|
465
|
+
create("strong", {
|
|
466
|
+
style: {
|
|
467
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
468
|
+
color: "var(--openapi-nullable)",
|
|
469
|
+
},
|
|
470
|
+
children: " nullable",
|
|
471
|
+
}),
|
|
472
|
+
]
|
|
473
|
+
),
|
|
474
|
+
guard(
|
|
475
|
+
Array.isArray(required)
|
|
476
|
+
? required.includes(name)
|
|
477
|
+
: required === true,
|
|
478
|
+
() => [
|
|
479
|
+
create("strong", {
|
|
480
|
+
style: {
|
|
481
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
482
|
+
color: "var(--openapi-required)",
|
|
483
|
+
},
|
|
484
|
+
children: " required",
|
|
485
|
+
}),
|
|
486
|
+
]
|
|
487
|
+
),
|
|
431
488
|
],
|
|
432
489
|
}),
|
|
433
490
|
create("div", {
|
|
@@ -558,7 +615,13 @@ function createEdges({
|
|
|
558
615
|
}
|
|
559
616
|
|
|
560
617
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
561
|
-
return createDetailsNode(
|
|
618
|
+
return createDetailsNode(
|
|
619
|
+
name,
|
|
620
|
+
schemaName,
|
|
621
|
+
schema,
|
|
622
|
+
required,
|
|
623
|
+
schema.nullable
|
|
624
|
+
);
|
|
562
625
|
}
|
|
563
626
|
|
|
564
627
|
if (schema.allOf !== undefined) {
|
|
@@ -573,20 +636,44 @@ function createEdges({
|
|
|
573
636
|
mergedSchemas.oneOf !== undefined ||
|
|
574
637
|
mergedSchemas.anyOf !== undefined
|
|
575
638
|
) {
|
|
576
|
-
return createDetailsNode(
|
|
639
|
+
return createDetailsNode(
|
|
640
|
+
name,
|
|
641
|
+
mergedSchemaName,
|
|
642
|
+
mergedSchemas,
|
|
643
|
+
required,
|
|
644
|
+
schema.nullable
|
|
645
|
+
);
|
|
577
646
|
}
|
|
578
647
|
|
|
579
648
|
if (mergedSchemas.properties !== undefined) {
|
|
580
|
-
return createDetailsNode(
|
|
649
|
+
return createDetailsNode(
|
|
650
|
+
name,
|
|
651
|
+
mergedSchemaName,
|
|
652
|
+
mergedSchemas,
|
|
653
|
+
required,
|
|
654
|
+
schema.nullable
|
|
655
|
+
);
|
|
581
656
|
}
|
|
582
657
|
|
|
583
658
|
if (mergedSchemas.additionalProperties !== undefined) {
|
|
584
|
-
return createDetailsNode(
|
|
659
|
+
return createDetailsNode(
|
|
660
|
+
name,
|
|
661
|
+
mergedSchemaName,
|
|
662
|
+
mergedSchemas,
|
|
663
|
+
required,
|
|
664
|
+
schema.nullable
|
|
665
|
+
);
|
|
585
666
|
}
|
|
586
667
|
|
|
587
668
|
// array of objects
|
|
588
669
|
if (mergedSchemas.items?.properties !== undefined) {
|
|
589
|
-
return createDetailsNode(
|
|
670
|
+
return createDetailsNode(
|
|
671
|
+
name,
|
|
672
|
+
mergedSchemaName,
|
|
673
|
+
mergedSchemas,
|
|
674
|
+
required,
|
|
675
|
+
schema.nullable
|
|
676
|
+
);
|
|
590
677
|
}
|
|
591
678
|
|
|
592
679
|
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
@@ -597,29 +684,51 @@ function createEdges({
|
|
|
597
684
|
collapsible: false,
|
|
598
685
|
name,
|
|
599
686
|
required: false,
|
|
600
|
-
deprecated: mergedSchemas.deprecated,
|
|
601
|
-
schemaDescription: mergedSchemas.description,
|
|
602
687
|
schemaName: schemaName,
|
|
603
688
|
qualifierMessage: getQualifierMessage(schema),
|
|
604
|
-
|
|
689
|
+
schema: mergedSchemas,
|
|
605
690
|
});
|
|
606
691
|
}
|
|
607
692
|
|
|
608
693
|
if (schema.properties !== undefined) {
|
|
609
|
-
return createDetailsNode(
|
|
694
|
+
return createDetailsNode(
|
|
695
|
+
name,
|
|
696
|
+
schemaName,
|
|
697
|
+
schema,
|
|
698
|
+
required,
|
|
699
|
+
schema.nullable
|
|
700
|
+
);
|
|
610
701
|
}
|
|
611
702
|
|
|
612
703
|
if (schema.additionalProperties !== undefined) {
|
|
613
|
-
return createDetailsNode(
|
|
704
|
+
return createDetailsNode(
|
|
705
|
+
name,
|
|
706
|
+
schemaName,
|
|
707
|
+
schema,
|
|
708
|
+
required,
|
|
709
|
+
schema.nullable
|
|
710
|
+
);
|
|
614
711
|
}
|
|
615
712
|
|
|
616
713
|
// array of objects
|
|
617
714
|
if (schema.items?.properties !== undefined) {
|
|
618
|
-
return createDetailsNode(
|
|
715
|
+
return createDetailsNode(
|
|
716
|
+
name,
|
|
717
|
+
schemaName,
|
|
718
|
+
schema,
|
|
719
|
+
required,
|
|
720
|
+
schema.nullable
|
|
721
|
+
);
|
|
619
722
|
}
|
|
620
723
|
|
|
621
724
|
if (schema.items?.anyOf !== undefined || schema.items?.oneOf !== undefined) {
|
|
622
|
-
return createDetailsNode(
|
|
725
|
+
return createDetailsNode(
|
|
726
|
+
name,
|
|
727
|
+
schemaName,
|
|
728
|
+
schema,
|
|
729
|
+
required,
|
|
730
|
+
schema.nullable
|
|
731
|
+
);
|
|
623
732
|
}
|
|
624
733
|
|
|
625
734
|
if (schema.writeOnly && schema.writeOnly === true) {
|
|
@@ -631,11 +740,9 @@ function createEdges({
|
|
|
631
740
|
collapsible: false,
|
|
632
741
|
name,
|
|
633
742
|
required: false,
|
|
634
|
-
deprecated: schema.deprecated,
|
|
635
|
-
schemaDescription: schema.description,
|
|
636
743
|
schemaName: schemaName,
|
|
637
744
|
qualifierMessage: getQualifierMessage(schema),
|
|
638
|
-
|
|
745
|
+
schema: schema,
|
|
639
746
|
});
|
|
640
747
|
}
|
|
641
748
|
|
|
@@ -643,34 +750,41 @@ function createEdges({
|
|
|
643
750
|
* Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
|
|
644
751
|
*/
|
|
645
752
|
function createNodes(schema: SchemaObject): any {
|
|
753
|
+
const nodes = [];
|
|
646
754
|
// if (schema.discriminator !== undefined) {
|
|
647
755
|
// return createDiscriminator(schema);
|
|
648
756
|
// }
|
|
649
757
|
|
|
650
758
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
651
|
-
|
|
759
|
+
nodes.push(createAnyOneOf(schema));
|
|
652
760
|
}
|
|
653
761
|
|
|
654
762
|
if (schema.allOf !== undefined) {
|
|
655
763
|
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
656
|
-
// allOf seems to always result in properties
|
|
657
764
|
if (mergedSchemas.properties !== undefined) {
|
|
658
|
-
|
|
765
|
+
nodes.push(createProperties(mergedSchemas));
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
if (mergedSchemas.items !== undefined) {
|
|
769
|
+
nodes.push(createItems(mergedSchemas));
|
|
659
770
|
}
|
|
660
771
|
}
|
|
661
772
|
|
|
662
773
|
if (schema.properties !== undefined) {
|
|
663
|
-
|
|
774
|
+
nodes.push(createProperties(schema));
|
|
664
775
|
}
|
|
665
776
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
return createAdditionalProperties(schema);
|
|
777
|
+
if (schema.additionalProperties !== undefined) {
|
|
778
|
+
nodes.push(createAdditionalProperties(schema));
|
|
669
779
|
}
|
|
670
780
|
|
|
671
781
|
// TODO: figure out how to handle array of objects
|
|
672
782
|
if (schema.items !== undefined) {
|
|
673
|
-
|
|
783
|
+
nodes.push(createItems(schema));
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
if (nodes.length && nodes.length > 0) {
|
|
787
|
+
return nodes.filter(Boolean).flat();
|
|
674
788
|
}
|
|
675
789
|
|
|
676
790
|
// primitive
|
|
@@ -704,7 +818,7 @@ function createNodes(schema: SchemaObject): any {
|
|
|
704
818
|
|
|
705
819
|
// Unknown node/schema type should return undefined
|
|
706
820
|
// So far, haven't seen this hit in testing
|
|
707
|
-
return
|
|
821
|
+
return "any";
|
|
708
822
|
}
|
|
709
823
|
|
|
710
824
|
interface Props {
|
|
@@ -738,7 +852,8 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
738
852
|
children: mimeTypes.map((mimeType: any) => {
|
|
739
853
|
const responseExamples = body.content![mimeType].examples;
|
|
740
854
|
const responseExample = body.content![mimeType].example;
|
|
741
|
-
const firstBody =
|
|
855
|
+
const firstBody: any =
|
|
856
|
+
body.content![mimeType].schema ?? body.content![mimeType];
|
|
742
857
|
|
|
743
858
|
if (
|
|
744
859
|
firstBody === undefined &&
|
|
@@ -776,12 +891,6 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
776
891
|
style: { textAlign: "left" },
|
|
777
892
|
children: [
|
|
778
893
|
create("strong", { children: `${title}` }),
|
|
779
|
-
guard(firstBody!.type === "array", (format) =>
|
|
780
|
-
create("span", {
|
|
781
|
-
style: { opacity: "0.6" },
|
|
782
|
-
children: ` array`,
|
|
783
|
-
})
|
|
784
|
-
),
|
|
785
894
|
guard(
|
|
786
895
|
body.required && body.required === true,
|
|
787
896
|
() => [
|
|
@@ -62,46 +62,45 @@ function createResponseHeaders(responseHeaders: any) {
|
|
|
62
62
|
create("ul", {
|
|
63
63
|
style: { marginLeft: "1rem" },
|
|
64
64
|
children: [
|
|
65
|
-
Object.entries(responseHeaders).map(
|
|
66
|
-
|
|
67
|
-
description,
|
|
68
|
-
|
|
69
|
-
example,
|
|
70
|
-
}: any = headerObj;
|
|
65
|
+
Object.entries(responseHeaders).map(
|
|
66
|
+
([headerName, headerObj]: [any, any]) => {
|
|
67
|
+
const { description, example }: any = headerObj;
|
|
68
|
+
const type = headerObj.schema?.type ?? "any";
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
70
|
+
return create("li", {
|
|
71
|
+
className: "schemaItem",
|
|
72
|
+
children: [
|
|
73
|
+
createDetailsSummary({
|
|
74
|
+
children: [
|
|
75
|
+
create("strong", { children: headerName }),
|
|
76
|
+
guard(type, () => [
|
|
77
|
+
create("span", {
|
|
78
|
+
style: { opacity: "0.6" },
|
|
79
|
+
children: ` ${type}`,
|
|
80
|
+
}),
|
|
81
|
+
]),
|
|
82
|
+
],
|
|
83
|
+
}),
|
|
84
|
+
create("div", {
|
|
85
|
+
children: [
|
|
86
|
+
guard(description, (description) =>
|
|
87
|
+
create("div", {
|
|
88
|
+
style: {
|
|
89
|
+
marginTop: ".5rem",
|
|
90
|
+
marginBottom: ".5rem",
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
guard(example, () => `Example: ${example}`),
|
|
94
|
+
createDescription(description),
|
|
95
|
+
],
|
|
96
|
+
})
|
|
97
|
+
),
|
|
98
|
+
],
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
),
|
|
105
104
|
],
|
|
106
105
|
})
|
|
107
106
|
);
|
|
@@ -120,14 +119,10 @@ export function createResponseExamples(
|
|
|
120
119
|
}
|
|
121
120
|
return Object.entries(responseExamples).map(
|
|
122
121
|
([exampleName, exampleValue]: any) => {
|
|
123
|
-
const camelToSpaceName = exampleName.replace(/([A-Z])/g, " $1");
|
|
124
|
-
let finalFormattedName =
|
|
125
|
-
camelToSpaceName.charAt(0).toUpperCase() + camelToSpaceName.slice(1);
|
|
126
|
-
|
|
127
122
|
if (typeof exampleValue.value === "object") {
|
|
128
123
|
return create("TabItem", {
|
|
129
|
-
label: `${
|
|
130
|
-
value: `${
|
|
124
|
+
label: `${exampleName}`,
|
|
125
|
+
value: `${exampleName}`,
|
|
131
126
|
children: [
|
|
132
127
|
guard(exampleValue.summary, (summary) => [
|
|
133
128
|
create("p", {
|
|
@@ -142,8 +137,8 @@ export function createResponseExamples(
|
|
|
142
137
|
});
|
|
143
138
|
}
|
|
144
139
|
return create("TabItem", {
|
|
145
|
-
label: `${
|
|
146
|
-
value: `${
|
|
140
|
+
label: `${exampleName}`,
|
|
141
|
+
value: `${exampleName}`,
|
|
147
142
|
children: [
|
|
148
143
|
guard(exampleValue.summary, (summary) => [
|
|
149
144
|
create("p", {
|
package/src/markdown/index.ts
CHANGED
|
@@ -88,7 +88,7 @@ export function createInfoPageMD({
|
|
|
88
88
|
}: InfoPageMetadata) {
|
|
89
89
|
return render([
|
|
90
90
|
`import ApiLogo from "@theme/ApiLogo";\n`,
|
|
91
|
-
`import
|
|
91
|
+
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
92
92
|
`import TabItem from "@theme/TabItem";\n`,
|
|
93
93
|
`import Export from "@theme/ApiDemoPanel/Export";\n\n`,
|
|
94
94
|
|