docusaurus-plugin-openapi-docs 0.0.0-396 → 0.0.0-399
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 +0 -1
- package/lib/markdown/createSchemaDetails.d.ts +1 -5
- package/lib/markdown/createSchemaDetails.js +318 -202
- package/lib/markdown/schema.js +3 -4
- package/lib/openapi/types.d.ts +1 -1
- package/package.json +2 -2
- package/src/markdown/createSchemaDetails.ts +388 -241
- package/src/markdown/schema.ts +3 -4
- package/src/openapi/types.ts +1 -1
- package/lib/markdown/createAnyOneOf.d.ts +0 -1
- package/lib/markdown/createAnyOneOf.js +0 -48
- package/src/markdown/createAnyOneOf.ts +0 -51
package/README.md
CHANGED
|
@@ -121,7 +121,6 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
|
|
|
121
121
|
| ---------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
122
122
|
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
|
|
123
123
|
| `ouputDir` | `string` | `null` | Desired output path for generated MDX files. |
|
|
124
|
-
| `ouputDir` | `string` | `null` | Desired output path for generated MDX files. |
|
|
125
124
|
| `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
|
|
126
125
|
| `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
|
|
127
126
|
| `version` | `string` | `null` | _Optional:_ Version assigned to single or micro-spec API specified in `specPath`. |
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { MediaTypeObject
|
|
2
|
-
interface RowsProps {
|
|
3
|
-
schema: SchemaObject;
|
|
4
|
-
}
|
|
5
|
-
export declare function createRows({ schema }: RowsProps): string | undefined;
|
|
1
|
+
import { MediaTypeObject } from "../openapi/types";
|
|
6
2
|
interface Props {
|
|
7
3
|
style?: any;
|
|
8
4
|
title: string;
|
|
@@ -6,17 +6,18 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.createSchemaDetails =
|
|
10
|
-
const createAnyOneOf_1 = require("./createAnyOneOf");
|
|
9
|
+
exports.createSchemaDetails = void 0;
|
|
11
10
|
const createDescription_1 = require("./createDescription");
|
|
12
11
|
const createDetails_1 = require("./createDetails");
|
|
13
12
|
const createDetailsSummary_1 = require("./createDetailsSummary");
|
|
14
13
|
const schema_1 = require("./schema");
|
|
15
14
|
const utils_1 = require("./utils");
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
|
|
16
|
+
/**
|
|
17
|
+
* Returns a merged representation of allOf array of schemas.
|
|
18
|
+
*/
|
|
19
|
+
function mergeAllOf(allOf) {
|
|
20
|
+
const mergedSchemas = jsonSchemaMergeAllOf(allOf, {
|
|
20
21
|
resolvers: {
|
|
21
22
|
readOnly: function () {
|
|
22
23
|
return true;
|
|
@@ -35,98 +36,284 @@ function resolveAllOf(allOf) {
|
|
|
35
36
|
}, []);
|
|
36
37
|
return { mergedSchemas, required };
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
39
|
+
/**
|
|
40
|
+
* For handling nested anyOf/oneOf.
|
|
41
|
+
*/
|
|
42
|
+
function createAnyOneOf(schema) {
|
|
43
|
+
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
44
|
+
return (0, utils_1.create)("li", {
|
|
45
|
+
children: [
|
|
46
|
+
(0, utils_1.create)("div", {
|
|
47
|
+
children: [
|
|
48
|
+
(0, utils_1.create)("span", {
|
|
49
|
+
className: "badge badge--info",
|
|
50
|
+
children: type,
|
|
51
|
+
}),
|
|
52
|
+
(0, utils_1.create)("SchemaTabs", {
|
|
53
|
+
children: schema[type].map((anyOneSchema, index) => {
|
|
54
|
+
const label = anyOneSchema.title
|
|
55
|
+
? anyOneSchema.title
|
|
56
|
+
: `MOD${index + 1}`;
|
|
57
|
+
const anyOneChildren = [];
|
|
58
|
+
if (anyOneSchema.properties !== undefined) {
|
|
59
|
+
anyOneChildren.push(createProperties(anyOneSchema));
|
|
60
|
+
}
|
|
61
|
+
if (anyOneSchema.allOf !== undefined) {
|
|
62
|
+
anyOneChildren.push(createNodes(anyOneSchema));
|
|
63
|
+
}
|
|
64
|
+
if (anyOneSchema.items !== undefined) {
|
|
65
|
+
anyOneChildren.push(createItems(anyOneSchema));
|
|
66
|
+
}
|
|
67
|
+
if (anyOneSchema.type === "string" ||
|
|
68
|
+
anyOneSchema.type === "number" ||
|
|
69
|
+
anyOneSchema.type === "integer" ||
|
|
70
|
+
anyOneSchema.type === "boolean") {
|
|
71
|
+
anyOneChildren.push(createNodes(anyOneSchema));
|
|
72
|
+
}
|
|
73
|
+
if (anyOneChildren.length) {
|
|
74
|
+
return (0, utils_1.create)("TabItem", {
|
|
75
|
+
label: label,
|
|
76
|
+
value: `${index}-item-properties`,
|
|
77
|
+
children: anyOneChildren,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
79
81
|
}),
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
}),
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function createProperties(schema) {
|
|
89
|
+
return Object.entries(schema.properties).map(([key, val]) => createEdges({
|
|
90
|
+
name: key,
|
|
91
|
+
schema: val,
|
|
92
|
+
required: Array.isArray(schema.required)
|
|
93
|
+
? schema.required.includes(key)
|
|
94
|
+
: false,
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
function createAdditionalProperties(schema) {
|
|
98
|
+
// TODO?:
|
|
99
|
+
// {
|
|
100
|
+
// description: 'Integration configuration. See \n' +
|
|
101
|
+
// '[Integration Configurations](https://prisma.pan.dev/api/cloud/api-integration-config/).\n',
|
|
102
|
+
// example: { webhookUrl: 'https://hooks.slack.com/abcdef' },
|
|
103
|
+
// externalDocs: { url: 'https://prisma.pan.dev/api/cloud/api-integration-config' },
|
|
104
|
+
// type: 'object'
|
|
105
|
+
// }
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
107
|
+
// TODO?:
|
|
108
|
+
// {
|
|
109
|
+
// items: {
|
|
110
|
+
// properties: {
|
|
111
|
+
// aliasField: [Object],
|
|
112
|
+
// displayName: [Object],
|
|
113
|
+
// fieldName: [Object],
|
|
114
|
+
// maxLength: [Object],
|
|
115
|
+
// options: [Object],
|
|
116
|
+
// redlockMapping: [Object],
|
|
117
|
+
// required: [Object],
|
|
118
|
+
// type: [Object],
|
|
119
|
+
// typeaheadUri: [Object],
|
|
120
|
+
// value: [Object]
|
|
121
|
+
// },
|
|
122
|
+
// type: 'object'
|
|
123
|
+
// },
|
|
124
|
+
// type: 'array'
|
|
125
|
+
// }
|
|
126
|
+
if (((_a = schema.additionalProperties) === null || _a === void 0 ? void 0 : _a.type) === "string" ||
|
|
127
|
+
((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "object" ||
|
|
128
|
+
((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "boolean" ||
|
|
129
|
+
((_d = schema.additionalProperties) === null || _d === void 0 ? void 0 : _d.type) === "integer" ||
|
|
130
|
+
((_e = schema.additionalProperties) === null || _e === void 0 ? void 0 : _e.type) === "number") {
|
|
131
|
+
const type = (_f = schema.additionalProperties) === null || _f === void 0 ? void 0 : _f.type;
|
|
132
|
+
const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
|
|
133
|
+
if (additionalProperties !== undefined) {
|
|
134
|
+
const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
|
|
135
|
+
const format = (_l = (_k = schema.additionalProperties) === null || _k === void 0 ? void 0 : _k.additionalProperties) === null || _l === void 0 ? void 0 : _l.format;
|
|
136
|
+
return (0, utils_1.create)("li", {
|
|
137
|
+
children: (0, utils_1.create)("div", {
|
|
138
|
+
children: [
|
|
139
|
+
(0, utils_1.create)("code", { children: `property name*` }),
|
|
140
|
+
(0, utils_1.guard)(type, (type) => (0, utils_1.create)("span", {
|
|
141
|
+
style: { opacity: "0.6" },
|
|
142
|
+
children: ` ${type}`,
|
|
143
|
+
})),
|
|
144
|
+
(0, utils_1.guard)(format, (format) => (0, utils_1.create)("span", {
|
|
145
|
+
style: { opacity: "0.6" },
|
|
146
|
+
children: ` (${format})`,
|
|
147
|
+
})),
|
|
148
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
|
|
149
|
+
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
150
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
151
|
+
})),
|
|
80
152
|
],
|
|
81
153
|
}),
|
|
82
|
-
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return (0, utils_1.create)("li", {
|
|
157
|
+
children: (0, utils_1.create)("div", {
|
|
158
|
+
children: [
|
|
159
|
+
(0, utils_1.create)("code", { children: `property name*` }),
|
|
160
|
+
(0, utils_1.guard)(type, (type) => (0, utils_1.create)("span", {
|
|
161
|
+
style: { opacity: "0.6" },
|
|
162
|
+
children: ` ${type}`,
|
|
163
|
+
})),
|
|
164
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
|
|
165
|
+
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
166
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
167
|
+
})),
|
|
168
|
+
],
|
|
169
|
+
}),
|
|
83
170
|
});
|
|
84
171
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
172
|
+
return Object.entries(schema.additionalProperties).map(([key, val]) => createEdges({
|
|
173
|
+
name: key,
|
|
174
|
+
schema: val,
|
|
175
|
+
required: Array.isArray(schema.required)
|
|
176
|
+
? schema.required.includes(key)
|
|
177
|
+
: false,
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
// TODO: figure out how to handle array of objects
|
|
181
|
+
function createItems(schema) {
|
|
182
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
183
|
+
if (((_a = schema.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
|
|
184
|
+
return createProperties(schema.items);
|
|
185
|
+
}
|
|
186
|
+
if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.additionalProperties) !== undefined) {
|
|
187
|
+
return createAdditionalProperties(schema.items);
|
|
188
|
+
}
|
|
189
|
+
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) {
|
|
190
|
+
return createAnyOneOf(schema.items);
|
|
191
|
+
}
|
|
192
|
+
if (((_e = schema.items) === null || _e === void 0 ? void 0 : _e.allOf) !== undefined) {
|
|
193
|
+
const { mergedSchemas } = mergeAllOf((_f = schema.items) === null || _f === void 0 ? void 0 : _f.allOf);
|
|
194
|
+
// Handles combo anyOf/oneOf + properties
|
|
195
|
+
if ((mergedSchemas.oneOf !== undefined ||
|
|
196
|
+
mergedSchemas.anyOf !== undefined) &&
|
|
197
|
+
mergedSchemas.properties) {
|
|
198
|
+
return (0, utils_1.create)("div", {
|
|
199
|
+
children: [
|
|
200
|
+
createAnyOneOf(mergedSchemas),
|
|
201
|
+
createProperties(mergedSchemas),
|
|
202
|
+
],
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// Handles only anyOf/oneOf
|
|
206
|
+
if (mergedSchemas.oneOf !== undefined ||
|
|
207
|
+
mergedSchemas.anyOf !== undefined) {
|
|
208
|
+
return (0, utils_1.create)("div", {
|
|
209
|
+
children: [
|
|
210
|
+
createAnyOneOf(mergedSchemas),
|
|
211
|
+
createProperties(mergedSchemas),
|
|
212
|
+
],
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (((_g = schema.items) === null || _g === void 0 ? void 0 : _g.type) === "string" ||
|
|
217
|
+
((_h = schema.items) === null || _h === void 0 ? void 0 : _h.type) === "number" ||
|
|
218
|
+
((_j = schema.items) === null || _j === void 0 ? void 0 : _j.type) === "integer" ||
|
|
219
|
+
((_k = schema.items) === null || _k === void 0 ? void 0 : _k.type) === "boolean") {
|
|
220
|
+
return createNodes(schema.items);
|
|
221
|
+
}
|
|
222
|
+
// TODO: clean this up or eliminate it?
|
|
223
|
+
return Object.entries(schema.items).map(([key, val]) => createEdges({
|
|
224
|
+
name: key,
|
|
225
|
+
schema: val,
|
|
226
|
+
required: Array.isArray(schema.required)
|
|
227
|
+
? schema.required.includes(key)
|
|
228
|
+
: false,
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
function createDetailsNode(name, schemaName, schema, required) {
|
|
232
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
233
|
+
collapsible: true,
|
|
234
|
+
className: "schemaItem",
|
|
235
|
+
children: [
|
|
236
|
+
(0, createDetails_1.createDetails)({
|
|
237
|
+
children: [
|
|
238
|
+
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
239
|
+
children: [
|
|
240
|
+
(0, utils_1.create)("strong", { children: name }),
|
|
241
|
+
(0, utils_1.create)("span", {
|
|
242
|
+
style: { opacity: "0.6" },
|
|
243
|
+
children: ` ${schemaName}`,
|
|
244
|
+
}),
|
|
245
|
+
(0, utils_1.guard)(required, () => [
|
|
246
|
+
(0, utils_1.create)("strong", {
|
|
247
|
+
style: {
|
|
248
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
249
|
+
color: "var(--openapi-required)",
|
|
250
|
+
},
|
|
251
|
+
children: " required",
|
|
98
252
|
}),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
253
|
+
]),
|
|
254
|
+
],
|
|
255
|
+
}),
|
|
256
|
+
(0, utils_1.create)("div", {
|
|
257
|
+
style: { marginLeft: "1rem" },
|
|
258
|
+
children: [
|
|
259
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
260
|
+
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
261
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
262
|
+
})),
|
|
263
|
+
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
264
|
+
style: { marginTop: ".5rem", marginBottom: ".5rem" },
|
|
265
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
266
|
+
})),
|
|
267
|
+
createNodes(schema),
|
|
268
|
+
],
|
|
269
|
+
}),
|
|
270
|
+
],
|
|
271
|
+
}),
|
|
272
|
+
],
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Creates the edges or "leaves" of a schema tree. Edges can branch into sub-nodes with createDetails().
|
|
277
|
+
*/
|
|
278
|
+
function createEdges({ name, schema, required }) {
|
|
279
|
+
var _a;
|
|
280
|
+
const schemaName = (0, schema_1.getSchemaName)(schema);
|
|
281
|
+
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
282
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
283
|
+
}
|
|
284
|
+
if (schema.allOf !== undefined) {
|
|
285
|
+
const { mergedSchemas, required, } = mergeAllOf(schema.allOf);
|
|
286
|
+
const mergedSchemaName = (0, schema_1.getSchemaName)(mergedSchemas);
|
|
287
|
+
if (mergedSchemas.oneOf !== undefined ||
|
|
288
|
+
mergedSchemas.anyOf !== undefined) {
|
|
289
|
+
return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
|
|
290
|
+
}
|
|
291
|
+
if (mergedSchemas.properties !== undefined) {
|
|
292
|
+
return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
|
|
293
|
+
}
|
|
294
|
+
if (mergedSchemas.additionalProperties !== undefined) {
|
|
295
|
+
return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
|
|
296
|
+
}
|
|
297
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
298
|
+
collapsible: false,
|
|
299
|
+
name,
|
|
300
|
+
required,
|
|
301
|
+
schemaDescription: mergedSchemas.description,
|
|
302
|
+
schemaName: schemaName,
|
|
303
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
127
304
|
});
|
|
128
305
|
}
|
|
129
|
-
|
|
306
|
+
if (schema.properties !== undefined) {
|
|
307
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
308
|
+
}
|
|
309
|
+
if (schema.additionalProperties !== undefined) {
|
|
310
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
311
|
+
}
|
|
312
|
+
// array of objects
|
|
313
|
+
if (((_a = schema.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
|
|
314
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
315
|
+
}
|
|
316
|
+
// primitives and array of non-objects
|
|
130
317
|
return (0, utils_1.create)("SchemaItem", {
|
|
131
318
|
collapsible: false,
|
|
132
319
|
name,
|
|
@@ -136,130 +323,55 @@ function createRow({ name, schema, required }) {
|
|
|
136
323
|
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
137
324
|
});
|
|
138
325
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (schema.anyOf !== undefined) {
|
|
146
|
-
return (0, createAnyOneOf_1.createAnyOneOf)(schema.anyOf, "anyOf");
|
|
326
|
+
/**
|
|
327
|
+
* Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
|
|
328
|
+
*/
|
|
329
|
+
function createNodes(schema) {
|
|
330
|
+
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
331
|
+
return createAnyOneOf(schema);
|
|
147
332
|
}
|
|
148
|
-
// object
|
|
149
|
-
if (schema.properties !== undefined) {
|
|
150
|
-
return (0, utils_1.create)("ul", {
|
|
151
|
-
children: Object.entries(schema.properties).map(([key, val]) => createRow({
|
|
152
|
-
name: key,
|
|
153
|
-
schema: val,
|
|
154
|
-
required: Array.isArray(schema.required)
|
|
155
|
-
? schema.required.includes(key)
|
|
156
|
-
: false,
|
|
157
|
-
})),
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
// allOf
|
|
161
333
|
if (schema.allOf !== undefined) {
|
|
162
|
-
const { mergedSchemas
|
|
163
|
-
//
|
|
164
|
-
if (mergedSchemas.oneOf !== undefined) {
|
|
165
|
-
return (0, createAnyOneOf_1.createAnyOneOf)(mergedSchemas.oneOf, "oneOf");
|
|
166
|
-
}
|
|
167
|
-
if (mergedSchemas.anyOf !== undefined) {
|
|
168
|
-
return (0, createAnyOneOf_1.createAnyOneOf)(mergedSchemas.anyOf, "anyOf");
|
|
169
|
-
}
|
|
170
|
-
// array
|
|
171
|
-
if (mergedSchemas.items !== undefined) {
|
|
172
|
-
return createRows({ schema: schema.items });
|
|
173
|
-
}
|
|
334
|
+
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
335
|
+
// allOf seems to always result in properties
|
|
174
336
|
if (mergedSchemas.properties !== undefined) {
|
|
175
|
-
return (
|
|
176
|
-
children: [
|
|
177
|
-
(0, utils_1.create)("span", {
|
|
178
|
-
className: "badge badge--info",
|
|
179
|
-
style: { marginBottom: "1rem" },
|
|
180
|
-
children: "allOf",
|
|
181
|
-
}),
|
|
182
|
-
Object.entries(mergedSchemas.properties).map(([key, val]) => createRow({
|
|
183
|
-
name: key,
|
|
184
|
-
schema: val,
|
|
185
|
-
required: Array.isArray(required)
|
|
186
|
-
? required.includes(key)
|
|
187
|
-
: false,
|
|
188
|
-
})),
|
|
189
|
-
],
|
|
190
|
-
});
|
|
337
|
+
return createProperties(mergedSchemas);
|
|
191
338
|
}
|
|
192
339
|
}
|
|
193
|
-
// primitive
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
exports.createRows = createRows;
|
|
197
|
-
function createRowsRoot({ schema }) {
|
|
198
|
-
// object
|
|
199
340
|
if (schema.properties !== undefined) {
|
|
200
|
-
return
|
|
201
|
-
name: key,
|
|
202
|
-
schema: val,
|
|
203
|
-
required: Array.isArray(schema.required)
|
|
204
|
-
? schema.required.includes(key)
|
|
205
|
-
: false,
|
|
206
|
-
}));
|
|
207
|
-
}
|
|
208
|
-
// allOf
|
|
209
|
-
if (schema.allOf !== undefined) {
|
|
210
|
-
const { mergedSchemas, required, } = resolveAllOf(schema.allOf);
|
|
211
|
-
return (0, utils_1.create)("div", {
|
|
212
|
-
children: [
|
|
213
|
-
(0, utils_1.create)("span", {
|
|
214
|
-
className: "badge badge--info",
|
|
215
|
-
style: { marginBottom: "1rem" },
|
|
216
|
-
children: "allOf",
|
|
217
|
-
}),
|
|
218
|
-
Object.entries(mergedSchemas.properties).map(([key, val]) => createRow({
|
|
219
|
-
name: key,
|
|
220
|
-
schema: val,
|
|
221
|
-
required: Array.isArray(required)
|
|
222
|
-
? required.includes(key)
|
|
223
|
-
: false,
|
|
224
|
-
})),
|
|
225
|
-
],
|
|
226
|
-
});
|
|
341
|
+
return createProperties(schema);
|
|
227
342
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return (0, createAnyOneOf_1.createAnyOneOf)(schema.oneOf, "oneOf");
|
|
343
|
+
if (schema.additionalProperties !== undefined) {
|
|
344
|
+
return createAdditionalProperties(schema);
|
|
231
345
|
}
|
|
232
|
-
//
|
|
233
|
-
if (schema.anyOf !== undefined) {
|
|
234
|
-
return (0, createAnyOneOf_1.createAnyOneOf)(schema.anyOf, "anyOf");
|
|
235
|
-
}
|
|
236
|
-
// array
|
|
346
|
+
// TODO: figure out how to handle array of objects
|
|
237
347
|
if (schema.items !== undefined) {
|
|
348
|
+
return createItems(schema);
|
|
349
|
+
}
|
|
350
|
+
// primitive
|
|
351
|
+
if (schema.type !== undefined) {
|
|
238
352
|
return (0, utils_1.create)("li", {
|
|
239
353
|
children: (0, utils_1.create)("div", {
|
|
240
|
-
children: [
|
|
354
|
+
children: [
|
|
355
|
+
(0, utils_1.create)("strong", { children: schema.type }),
|
|
356
|
+
(0, utils_1.guard)(schema.format, (format) => (0, utils_1.create)("span", {
|
|
357
|
+
style: { opacity: "0.6" },
|
|
358
|
+
children: ` ${format}`,
|
|
359
|
+
})),
|
|
360
|
+
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
361
|
+
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
362
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
363
|
+
})),
|
|
364
|
+
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
365
|
+
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
366
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
367
|
+
})),
|
|
368
|
+
],
|
|
241
369
|
}),
|
|
242
370
|
});
|
|
243
371
|
}
|
|
244
|
-
//
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
children: [
|
|
248
|
-
(0, utils_1.create)("span", {
|
|
249
|
-
style: { opacity: "0.6" },
|
|
250
|
-
children: ` ${schema.type}`,
|
|
251
|
-
}),
|
|
252
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
|
|
253
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
254
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
255
|
-
})),
|
|
256
|
-
(0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
|
|
257
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
258
|
-
children: (0, createDescription_1.createDescription)(description),
|
|
259
|
-
})),
|
|
260
|
-
],
|
|
261
|
-
}),
|
|
262
|
-
});
|
|
372
|
+
// Unknown node/schema type should return undefined
|
|
373
|
+
// So far, haven't seen this hit in testing
|
|
374
|
+
return undefined;
|
|
263
375
|
}
|
|
264
376
|
function createSchemaDetails({ title, body, ...rest }) {
|
|
265
377
|
if (body === undefined ||
|
|
@@ -268,7 +380,6 @@ function createSchemaDetails({ title, body, ...rest }) {
|
|
|
268
380
|
Object.keys(body.content).length === 0) {
|
|
269
381
|
return undefined;
|
|
270
382
|
}
|
|
271
|
-
// TODO:
|
|
272
383
|
// NOTE: We just pick a random content-type.
|
|
273
384
|
// How common is it to have multiple?
|
|
274
385
|
const randomFirstKey = Object.keys(body.content)[0];
|
|
@@ -282,6 +393,7 @@ function createSchemaDetails({ title, body, ...rest }) {
|
|
|
282
393
|
return undefined;
|
|
283
394
|
}
|
|
284
395
|
}
|
|
396
|
+
// Root-level schema dropdown
|
|
285
397
|
return (0, createDetails_1.createDetails)({
|
|
286
398
|
"data-collapsed": false,
|
|
287
399
|
open: true,
|
|
@@ -291,6 +403,10 @@ function createSchemaDetails({ title, body, ...rest }) {
|
|
|
291
403
|
style: { textAlign: "left" },
|
|
292
404
|
children: [
|
|
293
405
|
(0, utils_1.create)("strong", { children: `${title}` }),
|
|
406
|
+
(0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
|
|
407
|
+
style: { opacity: "0.6" },
|
|
408
|
+
children: ` array`,
|
|
409
|
+
})),
|
|
294
410
|
(0, utils_1.guard)(body.required, () => [
|
|
295
411
|
(0, utils_1.create)("strong", {
|
|
296
412
|
style: {
|
|
@@ -315,7 +431,7 @@ function createSchemaDetails({ title, body, ...rest }) {
|
|
|
315
431
|
}),
|
|
316
432
|
(0, utils_1.create)("ul", {
|
|
317
433
|
style: { marginLeft: "1rem" },
|
|
318
|
-
children:
|
|
434
|
+
children: createNodes(firstBody),
|
|
319
435
|
}),
|
|
320
436
|
],
|
|
321
437
|
});
|
package/lib/markdown/schema.js
CHANGED
|
@@ -54,10 +54,9 @@ function getQualifierMessage(schema) {
|
|
|
54
54
|
if (!schema) {
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// }
|
|
57
|
+
if (schema.items) {
|
|
58
|
+
return getQualifierMessage(schema.items);
|
|
59
|
+
}
|
|
61
60
|
let message = "**Possible values:** ";
|
|
62
61
|
let qualifierGroups = [];
|
|
63
62
|
if (schema.minLength || schema.maxLength) {
|
package/lib/openapi/types.d.ts
CHANGED
|
@@ -256,7 +256,7 @@ export declare type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" |
|
|
|
256
256
|
not?: SchemaObject;
|
|
257
257
|
items?: SchemaObject;
|
|
258
258
|
properties?: Map<SchemaObject>;
|
|
259
|
-
additionalProperties?:
|
|
259
|
+
additionalProperties?: Map<SchemaObject>;
|
|
260
260
|
nullable?: boolean;
|
|
261
261
|
discriminator?: DiscriminatorObject;
|
|
262
262
|
readOnly?: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-399",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=14"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "b42f88176b921b8871b87b95c08e5444e17b76b9"
|
|
71
71
|
}
|