docusaurus-plugin-openapi-docs 0.0.0-396 → 0.0.0-397

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.
@@ -1,8 +1,4 @@
1
- import { MediaTypeObject, SchemaObject } from "../openapi/types";
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 = exports.createRows = void 0;
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 mergeAllOf = require("json-schema-merge-allof");
17
- function resolveAllOf(allOf) {
18
- // Use external library to resolve and merge nested allOf schemas
19
- const mergedSchemas = mergeAllOf(allOf, {
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
- function createRow({ name, schema, required }) {
39
- const schemaName = (0, schema_1.getSchemaName)(schema);
40
- // array
41
- if (schema.type === "array" && schema.items) {
42
- return (0, utils_1.create)("SchemaItem", {
43
- collapsible: true,
44
- className: "schemaItem",
45
- children: [
46
- (0, createDetails_1.createDetails)({
47
- children: [
48
- (0, createDetailsSummary_1.createDetailsSummary)({
49
- children: [
50
- (0, utils_1.create)("strong", { children: name }),
51
- (0, utils_1.create)("span", {
52
- style: { opacity: "0.6" },
53
- children: ` ${schemaName}`,
54
- }),
55
- (0, utils_1.guard)(required, () => [
56
- (0, utils_1.create)("strong", {
57
- style: {
58
- fontSize: "var(--ifm-code-font-size)",
59
- color: "var(--openapi-required)",
60
- },
61
- children: " required",
62
- }),
63
- ]),
64
- ],
65
- }),
66
- (0, utils_1.create)("div", {
67
- style: { marginLeft: "1rem" },
68
- children: [
69
- (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
70
- style: { marginTop: ".5rem", marginBottom: ".5rem" },
71
- children: (0, createDescription_1.createDescription)(message),
72
- })),
73
- (0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
74
- style: { marginTop: ".5rem", marginBottom: ".5rem" },
75
- children: (0, createDescription_1.createDescription)(description),
76
- })),
77
- createRows({ schema: schema.items }),
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
- if (schemaName && (schemaName === "object" || schemaName === "object[]")) {
86
- return (0, utils_1.create)("SchemaItem", {
87
- collapsible: true,
88
- className: "schemaItem",
89
- children: [
90
- (0, createDetails_1.createDetails)({
91
- children: [
92
- (0, createDetailsSummary_1.createDetailsSummary)({
93
- children: [
94
- (0, utils_1.create)("strong", { children: name }),
95
- (0, utils_1.create)("span", {
96
- style: { opacity: "0.6" },
97
- children: ` ${schemaName}`,
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
- (0, utils_1.guard)(required, () => [
100
- (0, utils_1.create)("strong", {
101
- style: {
102
- fontSize: "var(--ifm-code-font-size)",
103
- color: "var(--openapi-required)",
104
- },
105
- children: " required",
106
- }),
107
- ]),
108
- ],
109
- }),
110
- (0, utils_1.create)("div", {
111
- style: { marginLeft: "1rem" },
112
- children: [
113
- (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
114
- style: { marginTop: ".5rem", marginBottom: ".5rem" },
115
- children: (0, createDescription_1.createDescription)(message),
116
- })),
117
- (0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
118
- style: { marginTop: ".5rem", marginBottom: ".5rem" },
119
- children: (0, createDescription_1.createDescription)(description),
120
- })),
121
- createRows({ schema: schema }),
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
- // primitive
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
- function createRows({ schema }) {
140
- // oneOf
141
- if (schema.oneOf !== undefined) {
142
- return (0, createAnyOneOf_1.createAnyOneOf)(schema.oneOf, "oneOf");
143
- }
144
- // anyOf
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, required, } = resolveAllOf(schema.allOf);
163
- // Adds support one more level deep
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 (0, utils_1.create)("div", {
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 Object.entries(schema.properties).map(([key, val]) => createRow({
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
- // oneOf
229
- if (schema.oneOf !== undefined) {
230
- return (0, createAnyOneOf_1.createAnyOneOf)(schema.oneOf, "oneOf");
343
+ if (schema.additionalProperties !== undefined) {
344
+ return createAdditionalProperties(schema);
231
345
  }
232
- // anyOf
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: [createRows({ schema: schema.items })],
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
- // primitive
245
- return (0, utils_1.create)("li", {
246
- children: (0, utils_1.create)("div", {
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: createRowsRoot({ schema: firstBody }),
434
+ children: createNodes(firstBody),
319
435
  }),
320
436
  ],
321
437
  });
@@ -54,10 +54,9 @@ function getQualifierMessage(schema) {
54
54
  if (!schema) {
55
55
  return undefined;
56
56
  }
57
- // TODO: This doesn't seem right
58
- // if (schema.items) {
59
- // return getQualifierMessage(schema.items);
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) {
@@ -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?: boolean | SchemaObject;
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-396",
4
+ "version": "0.0.0-397",
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": "958b9c6e0b370afe79572dfea950d2be33f41cc0"
70
+ "gitHead": "a830bbb4f0c32d17aedebc9503750a6aae9957cd"
71
71
  }