docusaurus-plugin-openapi-docs 0.0.0-619 → 0.0.0-685
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/markdown/createAuthorization.d.ts +1 -0
- package/lib/markdown/createAuthorization.js +16 -0
- package/lib/markdown/createDeprecationNotice.js +1 -1
- package/lib/markdown/createHeading.d.ts +1 -0
- package/lib/markdown/createHeading.js +20 -0
- package/lib/markdown/createMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createMethodEndpoint.js +14 -0
- package/lib/markdown/createParamsDetails.js +3 -1
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +13 -0
- package/lib/markdown/createRequestSchema.js +21 -17
- package/lib/markdown/createResponseSchema.js +8 -8
- package/lib/markdown/createSchema.d.ts +1 -1
- package/lib/markdown/createSchema.js +125 -86
- package/lib/markdown/createSchema.test.d.ts +1 -0
- package/lib/markdown/createSchema.test.js +73 -0
- package/lib/markdown/createStatusCodes.js +38 -35
- package/lib/markdown/index.d.ts +1 -1
- package/lib/markdown/index.js +15 -6
- package/lib/openapi/openapi.js +29 -13
- package/lib/openapi/openapi.test.js +1 -0
- package/lib/options.js +1 -2
- package/lib/sidebars/index.js +2 -2
- package/lib/types.d.ts +3 -1
- package/package.json +8 -16
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +98 -0
- package/src/markdown/createAuthorization.ts +13 -0
- package/src/markdown/createDeprecationNotice.ts +1 -1
- package/src/markdown/createHeading.ts +18 -0
- package/src/markdown/createMethodEndpoint.ts +12 -0
- package/src/markdown/createParamsDetails.ts +3 -1
- package/src/markdown/createRequestHeader.ts +10 -0
- package/src/markdown/createRequestSchema.ts +22 -17
- package/src/markdown/createResponseSchema.ts +9 -8
- package/src/markdown/createSchema.test.ts +56 -0
- package/src/markdown/createSchema.ts +140 -92
- package/src/markdown/createStatusCodes.ts +38 -35
- package/src/markdown/index.ts +17 -5
- package/src/openapi/openapi.test.ts +1 -0
- package/src/openapi/openapi.ts +25 -4
- package/src/options.ts +1 -2
- package/src/sidebars/index.ts +2 -2
- package/src/types.ts +3 -1
|
@@ -39,6 +39,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
39
39
|
|
|
40
40
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
41
41
|
return create("MimeTabs", {
|
|
42
|
+
className: "openapi-tabs__mime",
|
|
42
43
|
schemaType: "request",
|
|
43
44
|
children: mimeTypes.map((mimeType) => {
|
|
44
45
|
const firstBody = body.content![mimeType].schema;
|
|
@@ -55,21 +56,23 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
55
56
|
value: `${mimeType}`,
|
|
56
57
|
children: [
|
|
57
58
|
createDetails({
|
|
59
|
+
className: "openapi-markdown__details mime",
|
|
58
60
|
"data-collapsed": false,
|
|
59
61
|
open: true,
|
|
60
62
|
...rest,
|
|
61
63
|
children: [
|
|
62
64
|
createDetailsSummary({
|
|
63
|
-
|
|
65
|
+
className: "openapi-markdown__details-summary-mime",
|
|
64
66
|
children: [
|
|
65
|
-
create("
|
|
67
|
+
create("h3", {
|
|
68
|
+
className:
|
|
69
|
+
"openapi-markdown__details-summary-header-body",
|
|
70
|
+
children: `${title}`,
|
|
71
|
+
}),
|
|
66
72
|
guard(body.required && body.required === true, () => [
|
|
67
|
-
create("
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
color: "var(--openapi-required)",
|
|
71
|
-
},
|
|
72
|
-
children: " required",
|
|
73
|
+
create("span", {
|
|
74
|
+
className: "openapi-schema__required",
|
|
75
|
+
children: "required",
|
|
73
76
|
}),
|
|
74
77
|
]),
|
|
75
78
|
],
|
|
@@ -87,7 +90,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
87
90
|
}),
|
|
88
91
|
create("ul", {
|
|
89
92
|
style: { marginLeft: "1rem" },
|
|
90
|
-
children: createNodes(firstBody),
|
|
93
|
+
children: createNodes(firstBody, "request"),
|
|
91
94
|
}),
|
|
92
95
|
],
|
|
93
96
|
}),
|
|
@@ -112,20 +115,25 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
return create("MimeTabs", {
|
|
118
|
+
className: "openapi-tabs__mime",
|
|
115
119
|
children: [
|
|
116
120
|
create("TabItem", {
|
|
117
121
|
label: randomFirstKey,
|
|
118
122
|
value: `${randomFirstKey}-schema`,
|
|
119
123
|
children: [
|
|
120
124
|
createDetails({
|
|
125
|
+
className: "openapi-markdown__details mime",
|
|
121
126
|
"data-collapsed": false,
|
|
122
127
|
open: true,
|
|
123
128
|
...rest,
|
|
124
129
|
children: [
|
|
125
130
|
createDetailsSummary({
|
|
126
|
-
|
|
131
|
+
className: "openapi-markdown__details-summary-mime",
|
|
127
132
|
children: [
|
|
128
|
-
create("
|
|
133
|
+
create("h3", {
|
|
134
|
+
className: "openapi-markdown__details-summary-header-body",
|
|
135
|
+
children: `${title}`,
|
|
136
|
+
}),
|
|
129
137
|
guard(firstBody.type === "array", (format) =>
|
|
130
138
|
create("span", {
|
|
131
139
|
style: { opacity: "0.6" },
|
|
@@ -134,11 +142,8 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
134
142
|
),
|
|
135
143
|
guard(body.required, () => [
|
|
136
144
|
create("strong", {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
color: "var(--openapi-required)",
|
|
140
|
-
},
|
|
141
|
-
children: " required",
|
|
145
|
+
className: "openapi-schema__required",
|
|
146
|
+
children: "required",
|
|
142
147
|
}),
|
|
143
148
|
]),
|
|
144
149
|
],
|
|
@@ -156,7 +161,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
156
161
|
}),
|
|
157
162
|
create("ul", {
|
|
158
163
|
style: { marginLeft: "1rem" },
|
|
159
|
-
children: createNodes(firstBody),
|
|
164
|
+
children: createNodes(firstBody, "request"),
|
|
160
165
|
}),
|
|
161
166
|
],
|
|
162
167
|
}),
|
|
@@ -44,6 +44,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
44
44
|
|
|
45
45
|
if (mimeTypes && mimeTypes.length) {
|
|
46
46
|
return create("MimeTabs", {
|
|
47
|
+
className: "openapi-tabs__mime",
|
|
47
48
|
schemaType: "response",
|
|
48
49
|
children: mimeTypes.map((mimeType: any) => {
|
|
49
50
|
const responseExamples = body.content![mimeType].examples;
|
|
@@ -70,6 +71,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
70
71
|
value: `${mimeType}`,
|
|
71
72
|
children: [
|
|
72
73
|
create("SchemaTabs", {
|
|
74
|
+
className: "openapi-tabs__schema",
|
|
73
75
|
// TODO: determine if we should persist this
|
|
74
76
|
// groupId: "schema-tabs",
|
|
75
77
|
children: [
|
|
@@ -79,23 +81,22 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
79
81
|
value: `${title}`,
|
|
80
82
|
children: [
|
|
81
83
|
createDetails({
|
|
84
|
+
className: "openapi-markdown__details response",
|
|
82
85
|
"data-collapsed": false,
|
|
83
86
|
open: true,
|
|
84
87
|
...rest,
|
|
85
88
|
children: [
|
|
86
89
|
createDetailsSummary({
|
|
87
|
-
|
|
90
|
+
className:
|
|
91
|
+
"openapi-markdown__details-summary-response",
|
|
88
92
|
children: [
|
|
89
93
|
create("strong", { children: `${title}` }),
|
|
90
94
|
guard(
|
|
91
95
|
body.required && body.required === true,
|
|
92
96
|
() => [
|
|
93
|
-
create("
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
color: "var(--openapi-required)",
|
|
97
|
-
},
|
|
98
|
-
children: " required",
|
|
97
|
+
create("span", {
|
|
98
|
+
className: "openapi-schema__required",
|
|
99
|
+
children: "required",
|
|
99
100
|
}),
|
|
100
101
|
]
|
|
101
102
|
),
|
|
@@ -117,7 +118,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
117
118
|
}),
|
|
118
119
|
create("ul", {
|
|
119
120
|
style: { marginLeft: "1rem" },
|
|
120
|
-
children: createNodes(firstBody
|
|
121
|
+
children: createNodes(firstBody!, "response"),
|
|
121
122
|
}),
|
|
122
123
|
],
|
|
123
124
|
}),
|
|
@@ -0,0 +1,56 @@
|
|
|
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 * as prettier from "prettier";
|
|
9
|
+
|
|
10
|
+
import { SchemaObject } from "../openapi/types";
|
|
11
|
+
import { createNodes } from "./createSchema";
|
|
12
|
+
|
|
13
|
+
describe("createNodes", () => {
|
|
14
|
+
it("should create readable MODs for oneOf primitive properties", () => {
|
|
15
|
+
const schema: SchemaObject = {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
oneOfProperty: {
|
|
19
|
+
oneOf: [
|
|
20
|
+
{
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
noseLength: {
|
|
24
|
+
type: "number",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ["noseLength"],
|
|
28
|
+
description: "Clown's nose length",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "array",
|
|
32
|
+
items: {
|
|
33
|
+
type: "string",
|
|
34
|
+
},
|
|
35
|
+
description: "Array of strings",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "boolean",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "number",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "string",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
expect(
|
|
51
|
+
createNodes(schema, "request").map((md: any) =>
|
|
52
|
+
prettier.format(md, { parser: "babel" })
|
|
53
|
+
)
|
|
54
|
+
).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -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 { SchemaObject } from "../openapi/types";
|
|
9
11
|
import {
|
|
10
12
|
createClosingArrayBracket,
|
|
@@ -18,6 +20,8 @@ import { create, guard } from "./utils";
|
|
|
18
20
|
|
|
19
21
|
const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
|
|
20
22
|
|
|
23
|
+
let SCHEMA_TYPE: "request" | "response";
|
|
24
|
+
|
|
21
25
|
/**
|
|
22
26
|
* Returns a merged representation of allOf array of schemas.
|
|
23
27
|
*/
|
|
@@ -27,6 +31,9 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
27
31
|
readOnly: function () {
|
|
28
32
|
return true;
|
|
29
33
|
},
|
|
34
|
+
writeOnly: function () {
|
|
35
|
+
return true;
|
|
36
|
+
},
|
|
30
37
|
example: function () {
|
|
31
38
|
return true;
|
|
32
39
|
},
|
|
@@ -72,7 +79,7 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
if (anyOneSchema.allOf !== undefined) {
|
|
75
|
-
anyOneChildren.push(createNodes(anyOneSchema));
|
|
82
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
76
83
|
delete anyOneSchema.allOf;
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -87,7 +94,7 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
87
94
|
anyOneSchema.type === "integer" ||
|
|
88
95
|
anyOneSchema.type === "boolean"
|
|
89
96
|
) {
|
|
90
|
-
anyOneChildren.push(createNodes(anyOneSchema));
|
|
97
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
91
98
|
}
|
|
92
99
|
if (anyOneChildren.length) {
|
|
93
100
|
if (schema.type === "array") {
|
|
@@ -302,7 +309,7 @@ function createItems(schema: SchemaObject) {
|
|
|
302
309
|
) {
|
|
303
310
|
return [
|
|
304
311
|
createOpeningArrayBracket(),
|
|
305
|
-
createNodes(schema.items),
|
|
312
|
+
createNodes(schema.items, SCHEMA_TYPE),
|
|
306
313
|
createClosingArrayBracket(),
|
|
307
314
|
].flat();
|
|
308
315
|
}
|
|
@@ -338,41 +345,60 @@ function createDetailsNode(
|
|
|
338
345
|
className: "schemaItem",
|
|
339
346
|
children: [
|
|
340
347
|
createDetails({
|
|
348
|
+
className: "openapi-markdown__details",
|
|
341
349
|
children: [
|
|
342
350
|
createDetailsSummary({
|
|
343
351
|
children: [
|
|
344
|
-
create("strong", { children: name }),
|
|
345
352
|
create("span", {
|
|
346
|
-
|
|
347
|
-
children:
|
|
348
|
-
}),
|
|
349
|
-
guard(
|
|
350
|
-
(schema.nullable && schema.nullable === true) ||
|
|
351
|
-
(nullable && nullable === true),
|
|
352
|
-
() => [
|
|
353
|
+
className: "openapi-schema__container",
|
|
354
|
+
children: [
|
|
353
355
|
create("strong", {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
children: " nullable",
|
|
356
|
+
className: clsx("openapi-schema__property", {
|
|
357
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
358
|
+
}),
|
|
359
|
+
children: name,
|
|
359
360
|
}),
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
Array.isArray(required)
|
|
364
|
-
? required.includes(name)
|
|
365
|
-
: required === true,
|
|
366
|
-
() => [
|
|
367
|
-
create("strong", {
|
|
368
|
-
style: {
|
|
369
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
370
|
-
color: "var(--openapi-required)",
|
|
371
|
-
},
|
|
372
|
-
children: " required",
|
|
361
|
+
create("span", {
|
|
362
|
+
className: "openapi-schema__name",
|
|
363
|
+
children: ` ${schemaName}`,
|
|
373
364
|
}),
|
|
374
|
-
|
|
375
|
-
|
|
365
|
+
guard(
|
|
366
|
+
(Array.isArray(required)
|
|
367
|
+
? required.includes(name)
|
|
368
|
+
: required === true) ||
|
|
369
|
+
schema.deprecated ||
|
|
370
|
+
nullable,
|
|
371
|
+
() => [
|
|
372
|
+
create("span", {
|
|
373
|
+
className: "openapi-schema__divider",
|
|
374
|
+
}),
|
|
375
|
+
]
|
|
376
|
+
),
|
|
377
|
+
guard(nullable, () => [
|
|
378
|
+
create("span", {
|
|
379
|
+
className: "openapi-schema__nullable",
|
|
380
|
+
children: "nullable",
|
|
381
|
+
}),
|
|
382
|
+
]),
|
|
383
|
+
guard(
|
|
384
|
+
Array.isArray(required)
|
|
385
|
+
? required.includes(name)
|
|
386
|
+
: required === true,
|
|
387
|
+
() => [
|
|
388
|
+
create("span", {
|
|
389
|
+
className: "openapi-schema__required",
|
|
390
|
+
children: "required",
|
|
391
|
+
}),
|
|
392
|
+
]
|
|
393
|
+
),
|
|
394
|
+
guard(schema.deprecated, () => [
|
|
395
|
+
create("span", {
|
|
396
|
+
className: "openapi-schema__deprecated",
|
|
397
|
+
children: "deprecated",
|
|
398
|
+
}),
|
|
399
|
+
]),
|
|
400
|
+
],
|
|
401
|
+
}),
|
|
376
402
|
],
|
|
377
403
|
}),
|
|
378
404
|
create("div", {
|
|
@@ -390,7 +416,7 @@ function createDetailsNode(
|
|
|
390
416
|
children: createDescription(description),
|
|
391
417
|
})
|
|
392
418
|
),
|
|
393
|
-
createNodes(schema),
|
|
419
|
+
createNodes(schema, SCHEMA_TYPE),
|
|
394
420
|
],
|
|
395
421
|
}),
|
|
396
422
|
],
|
|
@@ -409,13 +435,12 @@ function createAnyOneOfProperty(
|
|
|
409
435
|
required: string[] | boolean,
|
|
410
436
|
nullable: boolean | unknown
|
|
411
437
|
): any {
|
|
412
|
-
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
413
|
-
const children = schema[type] || [];
|
|
414
438
|
return create("SchemaItem", {
|
|
415
439
|
collapsible: true,
|
|
416
440
|
className: "schemaItem",
|
|
417
441
|
children: [
|
|
418
442
|
createDetails({
|
|
443
|
+
className: "openapi-markdown__details",
|
|
419
444
|
children: [
|
|
420
445
|
createDetailsSummary({
|
|
421
446
|
children: [
|
|
@@ -470,39 +495,7 @@ function createAnyOneOfProperty(
|
|
|
470
495
|
),
|
|
471
496
|
],
|
|
472
497
|
}),
|
|
473
|
-
|
|
474
|
-
children: [
|
|
475
|
-
create("span", {
|
|
476
|
-
className: "badge badge--info",
|
|
477
|
-
children: type,
|
|
478
|
-
}),
|
|
479
|
-
create("SchemaTabs", {
|
|
480
|
-
children: children.map((property, index) => {
|
|
481
|
-
const label = property.title ?? `MOD${index + 1}`;
|
|
482
|
-
if (property.properties) {
|
|
483
|
-
return create("TabItem", {
|
|
484
|
-
label: label,
|
|
485
|
-
value: `${index}-property`,
|
|
486
|
-
children: [createNodes(property)],
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
return create("TabItem", {
|
|
490
|
-
label: label,
|
|
491
|
-
value: `${index}-property`,
|
|
492
|
-
children: [
|
|
493
|
-
create("p", { children: label }),
|
|
494
|
-
guard(schema.description, (description) =>
|
|
495
|
-
create("div", {
|
|
496
|
-
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
497
|
-
children: createDescription(description),
|
|
498
|
-
})
|
|
499
|
-
),
|
|
500
|
-
],
|
|
501
|
-
});
|
|
502
|
-
}),
|
|
503
|
-
}),
|
|
504
|
-
],
|
|
505
|
-
}),
|
|
498
|
+
createAnyOneOf(schema),
|
|
506
499
|
],
|
|
507
500
|
}),
|
|
508
501
|
],
|
|
@@ -519,7 +512,7 @@ function createPropertyDiscriminator(
|
|
|
519
512
|
schema: SchemaObject,
|
|
520
513
|
discriminator: any,
|
|
521
514
|
required: string[] | boolean
|
|
522
|
-
) {
|
|
515
|
+
): any {
|
|
523
516
|
if (schema === undefined) {
|
|
524
517
|
return undefined;
|
|
525
518
|
}
|
|
@@ -528,26 +521,61 @@ function createPropertyDiscriminator(
|
|
|
528
521
|
return undefined;
|
|
529
522
|
}
|
|
530
523
|
|
|
531
|
-
return create("
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
524
|
+
return create("div", {
|
|
525
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
526
|
+
children: create("div", {
|
|
527
|
+
children: [
|
|
528
|
+
create("span", {
|
|
529
|
+
className: "openapi-schema__container",
|
|
530
|
+
children: [
|
|
531
|
+
create("strong", {
|
|
532
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
533
|
+
children: name,
|
|
534
|
+
}),
|
|
535
|
+
guard(schemaName, (name) =>
|
|
536
|
+
create("span", {
|
|
537
|
+
className: "openapi-schema__name",
|
|
538
|
+
children: ` ${schemaName}`,
|
|
539
|
+
})
|
|
540
|
+
),
|
|
541
|
+
guard(required, () => [
|
|
542
|
+
create("span", {
|
|
543
|
+
className: "openapi-schema__required",
|
|
544
|
+
children: "required",
|
|
545
|
+
}),
|
|
546
|
+
]),
|
|
547
|
+
],
|
|
548
548
|
}),
|
|
549
|
-
|
|
550
|
-
|
|
549
|
+
guard(getQualifierMessage(discriminator), (message) =>
|
|
550
|
+
create("div", {
|
|
551
|
+
style: {
|
|
552
|
+
paddingLeft: "1rem",
|
|
553
|
+
},
|
|
554
|
+
children: createDescription(message),
|
|
555
|
+
})
|
|
556
|
+
),
|
|
557
|
+
guard(schema.description, (description) =>
|
|
558
|
+
create("div", {
|
|
559
|
+
style: {
|
|
560
|
+
paddingLeft: "1rem",
|
|
561
|
+
},
|
|
562
|
+
children: createDescription(description),
|
|
563
|
+
})
|
|
564
|
+
),
|
|
565
|
+
create("DiscriminatorTabs", {
|
|
566
|
+
className: "openapi-tabs__discriminator",
|
|
567
|
+
children: Object.keys(discriminator?.mapping!).map((key, index) => {
|
|
568
|
+
const label = key;
|
|
569
|
+
return create("TabItem", {
|
|
570
|
+
// className: "openapi-tabs__discriminator-item",
|
|
571
|
+
label: label,
|
|
572
|
+
value: `${index}-item-discriminator`,
|
|
573
|
+
children: [createNodes(discriminator?.mapping[key], SCHEMA_TYPE)],
|
|
574
|
+
});
|
|
575
|
+
}),
|
|
576
|
+
}),
|
|
577
|
+
],
|
|
578
|
+
}),
|
|
551
579
|
});
|
|
552
580
|
}
|
|
553
581
|
|
|
@@ -641,8 +669,16 @@ function createEdges({
|
|
|
641
669
|
);
|
|
642
670
|
}
|
|
643
671
|
|
|
644
|
-
if (
|
|
645
|
-
|
|
672
|
+
if (SCHEMA_TYPE === "request") {
|
|
673
|
+
if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
|
|
674
|
+
return undefined;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (SCHEMA_TYPE === "response") {
|
|
679
|
+
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
680
|
+
return undefined;
|
|
681
|
+
}
|
|
646
682
|
}
|
|
647
683
|
|
|
648
684
|
return create("SchemaItem", {
|
|
@@ -696,8 +732,16 @@ function createEdges({
|
|
|
696
732
|
);
|
|
697
733
|
}
|
|
698
734
|
|
|
699
|
-
if (
|
|
700
|
-
|
|
735
|
+
if (SCHEMA_TYPE === "request") {
|
|
736
|
+
if (schema.readOnly && schema.readOnly === true) {
|
|
737
|
+
return undefined;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
if (SCHEMA_TYPE === "response") {
|
|
742
|
+
if (schema.writeOnly && schema.writeOnly === true) {
|
|
743
|
+
return undefined;
|
|
744
|
+
}
|
|
701
745
|
}
|
|
702
746
|
|
|
703
747
|
// primitives and array of non-objects
|
|
@@ -714,7 +758,11 @@ function createEdges({
|
|
|
714
758
|
/**
|
|
715
759
|
* Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
|
|
716
760
|
*/
|
|
717
|
-
export function createNodes(
|
|
761
|
+
export function createNodes(
|
|
762
|
+
schema: SchemaObject,
|
|
763
|
+
schemaType: "request" | "response"
|
|
764
|
+
): any {
|
|
765
|
+
SCHEMA_TYPE = schemaType;
|
|
718
766
|
const nodes = [];
|
|
719
767
|
// if (schema.discriminator !== undefined) {
|
|
720
768
|
// return createDiscriminator(schema);
|
|
@@ -266,45 +266,48 @@ export function createStatusCodes({ responses }: Props) {
|
|
|
266
266
|
|
|
267
267
|
return create("div", {
|
|
268
268
|
children: [
|
|
269
|
-
create("
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
createDetailsSummary({
|
|
269
|
+
create("div", {
|
|
270
|
+
children: [
|
|
271
|
+
create("ApiTabs", {
|
|
272
|
+
children: codes.map((code) => {
|
|
273
|
+
const responseHeaders: any = responses[code].headers;
|
|
274
|
+
return create("TabItem", {
|
|
275
|
+
label: code,
|
|
276
|
+
value: code,
|
|
277
|
+
children: [
|
|
278
|
+
create("div", {
|
|
279
|
+
children: createDescription(responses[code].description),
|
|
280
|
+
}),
|
|
281
|
+
responseHeaders &&
|
|
282
|
+
createDetails({
|
|
283
|
+
className: "openapi-markdown__details",
|
|
284
|
+
"data-collaposed": true,
|
|
285
|
+
open: false,
|
|
286
|
+
style: { textAlign: "left", marginBottom: "1rem" },
|
|
288
287
|
children: [
|
|
289
|
-
|
|
290
|
-
children:
|
|
288
|
+
createDetailsSummary({
|
|
289
|
+
children: [
|
|
290
|
+
create("strong", {
|
|
291
|
+
children: "Response Headers",
|
|
292
|
+
}),
|
|
293
|
+
],
|
|
291
294
|
}),
|
|
295
|
+
createResponseHeaders(responseHeaders),
|
|
292
296
|
],
|
|
293
297
|
}),
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}),
|
|
298
|
+
create("div", {
|
|
299
|
+
children: createResponseSchema({
|
|
300
|
+
title: "Schema",
|
|
301
|
+
body: {
|
|
302
|
+
content: responses[code].content,
|
|
303
|
+
},
|
|
304
|
+
}),
|
|
305
|
+
}),
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
}),
|
|
309
|
+
}),
|
|
310
|
+
],
|
|
308
311
|
}),
|
|
309
312
|
],
|
|
310
313
|
});
|