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
package/README.md
CHANGED
|
@@ -31,15 +31,15 @@ Key Features:
|
|
|
31
31
|
|
|
32
32
|
| Docusaurus OpenAPI Docs | Docusaurus |
|
|
33
33
|
| ----------------------- | --------------- |
|
|
34
|
-
|
|
|
35
|
-
|
|
|
34
|
+
| 2.0.x (current) | `2.4.1 - 2.4.3` |
|
|
35
|
+
| 1.7.3 (legacy) | `2.0.1 - 2.2.0` |
|
|
36
36
|
|
|
37
37
|
## Bootstrapping from Template (new Docusaurus site)
|
|
38
38
|
|
|
39
39
|
Run the following to bootstrap a Docsaurus v2 site (classic theme) with `docusaurus-openapi-docs`:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
npx create-docusaurus@2.
|
|
42
|
+
npx create-docusaurus@2.4.3 my-website --package-manager yarn
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
> When prompted to select a template choose `Git repository`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createAuthorization(infoPath: string): string[] | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
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.createAuthorization = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createAuthorization(infoPath) {
|
|
12
|
+
if (!infoPath)
|
|
13
|
+
return undefined;
|
|
14
|
+
return [(0, utils_1.create)("SecuritySchemes", { infoPath: infoPath }), "\n\n"];
|
|
15
|
+
}
|
|
16
|
+
exports.createAuthorization = createAuthorization;
|
|
@@ -13,7 +13,7 @@ function createAdmonition({ children }) {
|
|
|
13
13
|
}
|
|
14
14
|
function createDeprecationNotice({ deprecated, description, }) {
|
|
15
15
|
return (0, utils_1.guard)(deprecated, () => createAdmonition({
|
|
16
|
-
children: description !== null && description !== void 0 ? description : "This endpoint has been deprecated and may be removed in future versions of the API.",
|
|
16
|
+
children: description !== null && description !== void 0 ? description : "This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
|
|
17
17
|
}));
|
|
18
18
|
}
|
|
19
19
|
exports.createDeprecationNotice = createDeprecationNotice;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createHeading(heading: string): string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
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.createHeading = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createHeading(heading) {
|
|
12
|
+
return [
|
|
13
|
+
(0, utils_1.create)("h1", {
|
|
14
|
+
className: "openapi__heading",
|
|
15
|
+
children: `${heading}`,
|
|
16
|
+
}),
|
|
17
|
+
`\n\n`,
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
exports.createHeading = createHeading;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createMethodEndpoint(method: String, path: String): string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
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.createMethodEndpoint = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createMethodEndpoint(method, path) {
|
|
12
|
+
return [(0, utils_1.create)("MethodEndpoint", { method: method, path: path }), "\n\n"];
|
|
13
|
+
}
|
|
14
|
+
exports.createMethodEndpoint = createMethodEndpoint;
|
|
@@ -19,13 +19,15 @@ function createParamsDetails({ parameters, type }) {
|
|
|
19
19
|
return undefined;
|
|
20
20
|
}
|
|
21
21
|
return (0, createDetails_1.createDetails)({
|
|
22
|
+
className: "openapi-markdown__details",
|
|
22
23
|
"data-collapsed": false,
|
|
23
24
|
open: true,
|
|
24
25
|
style: { marginBottom: "1rem" },
|
|
25
26
|
children: [
|
|
26
27
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
27
28
|
children: [
|
|
28
|
-
(0, utils_1.create)("
|
|
29
|
+
(0, utils_1.create)("h3", {
|
|
30
|
+
className: "openapi-markdown__details-summary-header-params",
|
|
29
31
|
children: `${type.charAt(0).toUpperCase() + type.slice(1)} Parameters`,
|
|
30
32
|
}),
|
|
31
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;
|
|
@@ -24,6 +24,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
24
24
|
const mimeTypes = Object.keys(body.content);
|
|
25
25
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
26
26
|
return (0, utils_1.create)("MimeTabs", {
|
|
27
|
+
className: "openapi-tabs__mime",
|
|
27
28
|
schemaType: "request",
|
|
28
29
|
children: mimeTypes.map((mimeType) => {
|
|
29
30
|
const firstBody = body.content[mimeType].schema;
|
|
@@ -40,21 +41,22 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
40
41
|
value: `${mimeType}`,
|
|
41
42
|
children: [
|
|
42
43
|
(0, createDetails_1.createDetails)({
|
|
44
|
+
className: "openapi-markdown__details mime",
|
|
43
45
|
"data-collapsed": false,
|
|
44
46
|
open: true,
|
|
45
47
|
...rest,
|
|
46
48
|
children: [
|
|
47
49
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
48
|
-
|
|
50
|
+
className: "openapi-markdown__details-summary-mime",
|
|
49
51
|
children: [
|
|
50
|
-
(0, utils_1.create)("
|
|
52
|
+
(0, utils_1.create)("h3", {
|
|
53
|
+
className: "openapi-markdown__details-summary-header-body",
|
|
54
|
+
children: `${title}`,
|
|
55
|
+
}),
|
|
51
56
|
(0, utils_1.guard)(body.required && body.required === true, () => [
|
|
52
|
-
(0, utils_1.create)("
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
color: "var(--openapi-required)",
|
|
56
|
-
},
|
|
57
|
-
children: " required",
|
|
57
|
+
(0, utils_1.create)("span", {
|
|
58
|
+
className: "openapi-schema__required",
|
|
59
|
+
children: "required",
|
|
58
60
|
}),
|
|
59
61
|
]),
|
|
60
62
|
],
|
|
@@ -72,7 +74,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
72
74
|
}),
|
|
73
75
|
(0, utils_1.create)("ul", {
|
|
74
76
|
style: { marginLeft: "1rem" },
|
|
75
|
-
children: (0, createSchema_1.createNodes)(firstBody),
|
|
77
|
+
children: (0, createSchema_1.createNodes)(firstBody, "request"),
|
|
76
78
|
}),
|
|
77
79
|
],
|
|
78
80
|
}),
|
|
@@ -93,31 +95,33 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
return (0, utils_1.create)("MimeTabs", {
|
|
98
|
+
className: "openapi-tabs__mime",
|
|
96
99
|
children: [
|
|
97
100
|
(0, utils_1.create)("TabItem", {
|
|
98
101
|
label: randomFirstKey,
|
|
99
102
|
value: `${randomFirstKey}-schema`,
|
|
100
103
|
children: [
|
|
101
104
|
(0, createDetails_1.createDetails)({
|
|
105
|
+
className: "openapi-markdown__details mime",
|
|
102
106
|
"data-collapsed": false,
|
|
103
107
|
open: true,
|
|
104
108
|
...rest,
|
|
105
109
|
children: [
|
|
106
110
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
107
|
-
|
|
111
|
+
className: "openapi-markdown__details-summary-mime",
|
|
108
112
|
children: [
|
|
109
|
-
(0, utils_1.create)("
|
|
113
|
+
(0, utils_1.create)("h3", {
|
|
114
|
+
className: "openapi-markdown__details-summary-header-body",
|
|
115
|
+
children: `${title}`,
|
|
116
|
+
}),
|
|
110
117
|
(0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
|
|
111
118
|
style: { opacity: "0.6" },
|
|
112
119
|
children: ` array`,
|
|
113
120
|
})),
|
|
114
121
|
(0, utils_1.guard)(body.required, () => [
|
|
115
122
|
(0, utils_1.create)("strong", {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
color: "var(--openapi-required)",
|
|
119
|
-
},
|
|
120
|
-
children: " required",
|
|
123
|
+
className: "openapi-schema__required",
|
|
124
|
+
children: "required",
|
|
121
125
|
}),
|
|
122
126
|
]),
|
|
123
127
|
],
|
|
@@ -135,7 +139,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
135
139
|
}),
|
|
136
140
|
(0, utils_1.create)("ul", {
|
|
137
141
|
style: { marginLeft: "1rem" },
|
|
138
|
-
children: (0, createSchema_1.createNodes)(firstBody),
|
|
142
|
+
children: (0, createSchema_1.createNodes)(firstBody, "request"),
|
|
139
143
|
}),
|
|
140
144
|
],
|
|
141
145
|
}),
|
|
@@ -24,6 +24,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
24
24
|
const mimeTypes = Object.keys(body.content);
|
|
25
25
|
if (mimeTypes && mimeTypes.length) {
|
|
26
26
|
return (0, utils_1.create)("MimeTabs", {
|
|
27
|
+
className: "openapi-tabs__mime",
|
|
27
28
|
schemaType: "response",
|
|
28
29
|
children: mimeTypes.map((mimeType) => {
|
|
29
30
|
var _a;
|
|
@@ -45,6 +46,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
45
46
|
value: `${mimeType}`,
|
|
46
47
|
children: [
|
|
47
48
|
(0, utils_1.create)("SchemaTabs", {
|
|
49
|
+
className: "openapi-tabs__schema",
|
|
48
50
|
// TODO: determine if we should persist this
|
|
49
51
|
// groupId: "schema-tabs",
|
|
50
52
|
children: [
|
|
@@ -54,21 +56,19 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
54
56
|
value: `${title}`,
|
|
55
57
|
children: [
|
|
56
58
|
(0, createDetails_1.createDetails)({
|
|
59
|
+
className: "openapi-markdown__details response",
|
|
57
60
|
"data-collapsed": false,
|
|
58
61
|
open: true,
|
|
59
62
|
...rest,
|
|
60
63
|
children: [
|
|
61
64
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
62
|
-
|
|
65
|
+
className: "openapi-markdown__details-summary-response",
|
|
63
66
|
children: [
|
|
64
67
|
(0, utils_1.create)("strong", { children: `${title}` }),
|
|
65
68
|
(0, utils_1.guard)(body.required && body.required === true, () => [
|
|
66
|
-
(0, utils_1.create)("
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
color: "var(--openapi-required)",
|
|
70
|
-
},
|
|
71
|
-
children: " required",
|
|
69
|
+
(0, utils_1.create)("span", {
|
|
70
|
+
className: "openapi-schema__required",
|
|
71
|
+
children: "required",
|
|
72
72
|
}),
|
|
73
73
|
]),
|
|
74
74
|
],
|
|
@@ -89,7 +89,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
89
89
|
}),
|
|
90
90
|
(0, utils_1.create)("ul", {
|
|
91
91
|
style: { marginLeft: "1rem" },
|
|
92
|
-
children: (0, createSchema_1.createNodes)(firstBody),
|
|
92
|
+
children: (0, createSchema_1.createNodes)(firstBody, "response"),
|
|
93
93
|
}),
|
|
94
94
|
],
|
|
95
95
|
}),
|
|
@@ -9,4 +9,4 @@ export declare function mergeAllOf(allOf: SchemaObject[]): {
|
|
|
9
9
|
/**
|
|
10
10
|
* Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
|
|
11
11
|
*/
|
|
12
|
-
export declare function createNodes(schema: SchemaObject): any;
|
|
12
|
+
export declare function createNodes(schema: SchemaObject, schemaType: "request" | "response"): any;
|
|
@@ -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.createNodes = 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");
|
|
@@ -14,6 +18,7 @@ const createDetailsSummary_1 = require("./createDetailsSummary");
|
|
|
14
18
|
const schema_1 = require("./schema");
|
|
15
19
|
const utils_1 = require("./utils");
|
|
16
20
|
const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
|
|
21
|
+
let SCHEMA_TYPE;
|
|
17
22
|
/**
|
|
18
23
|
* Returns a merged representation of allOf array of schemas.
|
|
19
24
|
*/
|
|
@@ -23,6 +28,9 @@ function mergeAllOf(allOf) {
|
|
|
23
28
|
readOnly: function () {
|
|
24
29
|
return true;
|
|
25
30
|
},
|
|
31
|
+
writeOnly: function () {
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
26
34
|
example: function () {
|
|
27
35
|
return true;
|
|
28
36
|
},
|
|
@@ -64,7 +72,7 @@ function createAnyOneOf(schema) {
|
|
|
64
72
|
delete anyOneSchema.properties;
|
|
65
73
|
}
|
|
66
74
|
if (anyOneSchema.allOf !== undefined) {
|
|
67
|
-
anyOneChildren.push(createNodes(anyOneSchema));
|
|
75
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
68
76
|
delete anyOneSchema.allOf;
|
|
69
77
|
}
|
|
70
78
|
if (anyOneSchema.items !== undefined) {
|
|
@@ -75,7 +83,7 @@ function createAnyOneOf(schema) {
|
|
|
75
83
|
anyOneSchema.type === "number" ||
|
|
76
84
|
anyOneSchema.type === "integer" ||
|
|
77
85
|
anyOneSchema.type === "boolean") {
|
|
78
|
-
anyOneChildren.push(createNodes(anyOneSchema));
|
|
86
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
79
87
|
}
|
|
80
88
|
if (anyOneChildren.length) {
|
|
81
89
|
if (schema.type === "array") {
|
|
@@ -253,7 +261,7 @@ function createItems(schema) {
|
|
|
253
261
|
((_l = schema.items) === null || _l === void 0 ? void 0 : _l.type) === "object") {
|
|
254
262
|
return [
|
|
255
263
|
(0, createArrayBracket_1.createOpeningArrayBracket)(),
|
|
256
|
-
createNodes(schema.items),
|
|
264
|
+
createNodes(schema.items, SCHEMA_TYPE),
|
|
257
265
|
(0, createArrayBracket_1.createClosingArrayBracket)(),
|
|
258
266
|
].flat();
|
|
259
267
|
}
|
|
@@ -279,35 +287,54 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
279
287
|
className: "schemaItem",
|
|
280
288
|
children: [
|
|
281
289
|
(0, createDetails_1.createDetails)({
|
|
290
|
+
className: "openapi-markdown__details",
|
|
282
291
|
children: [
|
|
283
292
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
284
293
|
children: [
|
|
285
|
-
(0, utils_1.create)("strong", { children: name }),
|
|
286
294
|
(0, utils_1.create)("span", {
|
|
287
|
-
|
|
288
|
-
children:
|
|
295
|
+
className: "openapi-schema__container",
|
|
296
|
+
children: [
|
|
297
|
+
(0, utils_1.create)("strong", {
|
|
298
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
299
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
300
|
+
}),
|
|
301
|
+
children: name,
|
|
302
|
+
}),
|
|
303
|
+
(0, utils_1.create)("span", {
|
|
304
|
+
className: "openapi-schema__name",
|
|
305
|
+
children: ` ${schemaName}`,
|
|
306
|
+
}),
|
|
307
|
+
(0, utils_1.guard)((Array.isArray(required)
|
|
308
|
+
? required.includes(name)
|
|
309
|
+
: required === true) ||
|
|
310
|
+
schema.deprecated ||
|
|
311
|
+
nullable, () => [
|
|
312
|
+
(0, utils_1.create)("span", {
|
|
313
|
+
className: "openapi-schema__divider",
|
|
314
|
+
}),
|
|
315
|
+
]),
|
|
316
|
+
(0, utils_1.guard)(nullable, () => [
|
|
317
|
+
(0, utils_1.create)("span", {
|
|
318
|
+
className: "openapi-schema__nullable",
|
|
319
|
+
children: "nullable",
|
|
320
|
+
}),
|
|
321
|
+
]),
|
|
322
|
+
(0, utils_1.guard)(Array.isArray(required)
|
|
323
|
+
? required.includes(name)
|
|
324
|
+
: required === true, () => [
|
|
325
|
+
(0, utils_1.create)("span", {
|
|
326
|
+
className: "openapi-schema__required",
|
|
327
|
+
children: "required",
|
|
328
|
+
}),
|
|
329
|
+
]),
|
|
330
|
+
(0, utils_1.guard)(schema.deprecated, () => [
|
|
331
|
+
(0, utils_1.create)("span", {
|
|
332
|
+
className: "openapi-schema__deprecated",
|
|
333
|
+
children: "deprecated",
|
|
334
|
+
}),
|
|
335
|
+
]),
|
|
336
|
+
],
|
|
289
337
|
}),
|
|
290
|
-
(0, utils_1.guard)((schema.nullable && schema.nullable === true) ||
|
|
291
|
-
(nullable && nullable === true), () => [
|
|
292
|
-
(0, utils_1.create)("strong", {
|
|
293
|
-
style: {
|
|
294
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
295
|
-
color: "var(--openapi-nullable)",
|
|
296
|
-
},
|
|
297
|
-
children: " nullable",
|
|
298
|
-
}),
|
|
299
|
-
]),
|
|
300
|
-
(0, utils_1.guard)(Array.isArray(required)
|
|
301
|
-
? required.includes(name)
|
|
302
|
-
: required === true, () => [
|
|
303
|
-
(0, utils_1.create)("strong", {
|
|
304
|
-
style: {
|
|
305
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
306
|
-
color: "var(--openapi-required)",
|
|
307
|
-
},
|
|
308
|
-
children: " required",
|
|
309
|
-
}),
|
|
310
|
-
]),
|
|
311
338
|
],
|
|
312
339
|
}),
|
|
313
340
|
(0, utils_1.create)("div", {
|
|
@@ -321,7 +348,7 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
321
348
|
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
322
349
|
children: (0, createDescription_1.createDescription)(description),
|
|
323
350
|
})),
|
|
324
|
-
createNodes(schema),
|
|
351
|
+
createNodes(schema, SCHEMA_TYPE),
|
|
325
352
|
],
|
|
326
353
|
}),
|
|
327
354
|
],
|
|
@@ -333,13 +360,12 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
333
360
|
* For handling anyOf/oneOf properties.
|
|
334
361
|
*/
|
|
335
362
|
function createAnyOneOfProperty(name, schemaName, schema, required, nullable) {
|
|
336
|
-
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
337
|
-
const children = schema[type] || [];
|
|
338
363
|
return (0, utils_1.create)("SchemaItem", {
|
|
339
364
|
collapsible: true,
|
|
340
365
|
className: "schemaItem",
|
|
341
366
|
children: [
|
|
342
367
|
(0, createDetails_1.createDetails)({
|
|
368
|
+
className: "openapi-markdown__details",
|
|
343
369
|
children: [
|
|
344
370
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
345
371
|
children: [
|
|
@@ -384,38 +410,7 @@ function createAnyOneOfProperty(name, schemaName, schema, required, nullable) {
|
|
|
384
410
|
})),
|
|
385
411
|
],
|
|
386
412
|
}),
|
|
387
|
-
(
|
|
388
|
-
children: [
|
|
389
|
-
(0, utils_1.create)("span", {
|
|
390
|
-
className: "badge badge--info",
|
|
391
|
-
children: type,
|
|
392
|
-
}),
|
|
393
|
-
(0, utils_1.create)("SchemaTabs", {
|
|
394
|
-
children: children.map((property, index) => {
|
|
395
|
-
var _a;
|
|
396
|
-
const label = (_a = property.title) !== null && _a !== void 0 ? _a : `MOD${index + 1}`;
|
|
397
|
-
if (property.properties) {
|
|
398
|
-
return (0, utils_1.create)("TabItem", {
|
|
399
|
-
label: label,
|
|
400
|
-
value: `${index}-property`,
|
|
401
|
-
children: [createNodes(property)],
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
return (0, utils_1.create)("TabItem", {
|
|
405
|
-
label: label,
|
|
406
|
-
value: `${index}-property`,
|
|
407
|
-
children: [
|
|
408
|
-
(0, utils_1.create)("p", { children: label }),
|
|
409
|
-
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
410
|
-
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
411
|
-
children: (0, createDescription_1.createDescription)(description),
|
|
412
|
-
})),
|
|
413
|
-
],
|
|
414
|
-
});
|
|
415
|
-
}),
|
|
416
|
-
}),
|
|
417
|
-
],
|
|
418
|
-
}),
|
|
413
|
+
createAnyOneOf(schema),
|
|
419
414
|
],
|
|
420
415
|
}),
|
|
421
416
|
],
|
|
@@ -432,26 +427,55 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
432
427
|
if (discriminator.mapping === undefined) {
|
|
433
428
|
return undefined;
|
|
434
429
|
}
|
|
435
|
-
return (0, utils_1.create)("
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
430
|
+
return (0, utils_1.create)("div", {
|
|
431
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
432
|
+
children: (0, utils_1.create)("div", {
|
|
433
|
+
children: [
|
|
434
|
+
(0, utils_1.create)("span", {
|
|
435
|
+
className: "openapi-schema__container",
|
|
436
|
+
children: [
|
|
437
|
+
(0, utils_1.create)("strong", {
|
|
438
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
439
|
+
children: name,
|
|
440
|
+
}),
|
|
441
|
+
(0, utils_1.guard)(schemaName, (name) => (0, utils_1.create)("span", {
|
|
442
|
+
className: "openapi-schema__name",
|
|
443
|
+
children: ` ${schemaName}`,
|
|
444
|
+
})),
|
|
445
|
+
(0, utils_1.guard)(required, () => [
|
|
446
|
+
(0, utils_1.create)("span", {
|
|
447
|
+
className: "openapi-schema__required",
|
|
448
|
+
children: "required",
|
|
449
|
+
}),
|
|
450
|
+
]),
|
|
451
|
+
],
|
|
452
452
|
}),
|
|
453
|
-
|
|
454
|
-
|
|
453
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
|
|
454
|
+
style: {
|
|
455
|
+
paddingLeft: "1rem",
|
|
456
|
+
},
|
|
457
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
458
|
+
})),
|
|
459
|
+
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
460
|
+
style: {
|
|
461
|
+
paddingLeft: "1rem",
|
|
462
|
+
},
|
|
463
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
464
|
+
})),
|
|
465
|
+
(0, utils_1.create)("DiscriminatorTabs", {
|
|
466
|
+
className: "openapi-tabs__discriminator",
|
|
467
|
+
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
468
|
+
const label = key;
|
|
469
|
+
return (0, utils_1.create)("TabItem", {
|
|
470
|
+
// className: "openapi-tabs__discriminator-item",
|
|
471
|
+
label: label,
|
|
472
|
+
value: `${index}-item-discriminator`,
|
|
473
|
+
children: [createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key], SCHEMA_TYPE)],
|
|
474
|
+
});
|
|
475
|
+
}),
|
|
476
|
+
}),
|
|
477
|
+
],
|
|
478
|
+
}),
|
|
455
479
|
});
|
|
456
480
|
}
|
|
457
481
|
/**
|
|
@@ -483,8 +507,15 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
483
507
|
if (((_a = mergedSchemas.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
|
|
484
508
|
return createDetailsNode(name, mergedSchemaName, mergedSchemas, required, schema.nullable);
|
|
485
509
|
}
|
|
486
|
-
if (
|
|
487
|
-
|
|
510
|
+
if (SCHEMA_TYPE === "request") {
|
|
511
|
+
if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
|
|
512
|
+
return undefined;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (SCHEMA_TYPE === "response") {
|
|
516
|
+
if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
|
|
517
|
+
return undefined;
|
|
518
|
+
}
|
|
488
519
|
}
|
|
489
520
|
return (0, utils_1.create)("SchemaItem", {
|
|
490
521
|
collapsible: false,
|
|
@@ -508,8 +539,15 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
508
539
|
if (((_c = schema.items) === null || _c === void 0 ? void 0 : _c.anyOf) !== undefined || ((_d = schema.items) === null || _d === void 0 ? void 0 : _d.oneOf) !== undefined) {
|
|
509
540
|
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
510
541
|
}
|
|
511
|
-
if (
|
|
512
|
-
|
|
542
|
+
if (SCHEMA_TYPE === "request") {
|
|
543
|
+
if (schema.readOnly && schema.readOnly === true) {
|
|
544
|
+
return undefined;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (SCHEMA_TYPE === "response") {
|
|
548
|
+
if (schema.writeOnly && schema.writeOnly === true) {
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
513
551
|
}
|
|
514
552
|
// primitives and array of non-objects
|
|
515
553
|
return (0, utils_1.create)("SchemaItem", {
|
|
@@ -524,7 +562,8 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
524
562
|
/**
|
|
525
563
|
* Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
|
|
526
564
|
*/
|
|
527
|
-
function createNodes(schema) {
|
|
565
|
+
function createNodes(schema, schemaType) {
|
|
566
|
+
SCHEMA_TYPE = schemaType;
|
|
528
567
|
const nodes = [];
|
|
529
568
|
// if (schema.discriminator !== undefined) {
|
|
530
569
|
// return createDiscriminator(schema);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|