docusaurus-plugin-openapi-docs 1.1.4 → 1.1.7

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.
@@ -0,0 +1,14 @@
1
+ import { MediaTypeObject } from "../openapi/types";
2
+ interface Props {
3
+ style?: any;
4
+ title: string;
5
+ body: {
6
+ content?: {
7
+ [key: string]: MediaTypeObject;
8
+ };
9
+ description?: string;
10
+ required?: string[] | boolean;
11
+ };
12
+ }
13
+ export declare function createResponseSchema({ title, body, ...rest }: Props): string | undefined;
14
+ export {};
@@ -0,0 +1,641 @@
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.createResponseSchema = void 0;
10
+ const createDescription_1 = require("./createDescription");
11
+ const createDetails_1 = require("./createDetails");
12
+ const createDetailsSummary_1 = require("./createDetailsSummary");
13
+ const createStatusCodes_1 = require("./createStatusCodes");
14
+ const schema_1 = require("./schema");
15
+ const utils_1 = require("./utils");
16
+ const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
17
+ /**
18
+ * Returns a merged representation of allOf array of schemas.
19
+ */
20
+ function mergeAllOf(allOf) {
21
+ const mergedSchemas = jsonSchemaMergeAllOf(allOf, {
22
+ resolvers: {
23
+ readOnly: function () {
24
+ return true;
25
+ },
26
+ example: function () {
27
+ return true;
28
+ },
29
+ },
30
+ });
31
+ const required = allOf.reduce((acc, cur) => {
32
+ if (Array.isArray(cur.required)) {
33
+ const next = [...acc, ...cur.required];
34
+ return next;
35
+ }
36
+ return acc;
37
+ }, []);
38
+ return { mergedSchemas, required };
39
+ }
40
+ /**
41
+ * For handling nested anyOf/oneOf.
42
+ */
43
+ function createAnyOneOf(schema) {
44
+ const type = schema.oneOf ? "oneOf" : "anyOf";
45
+ return (0, utils_1.create)("li", {
46
+ children: [
47
+ (0, utils_1.create)("div", {
48
+ children: [
49
+ (0, utils_1.create)("span", {
50
+ className: "badge badge--info",
51
+ children: type,
52
+ }),
53
+ (0, utils_1.create)("SchemaTabs", {
54
+ children: schema[type].map((anyOneSchema, index) => {
55
+ const label = anyOneSchema.title
56
+ ? anyOneSchema.title
57
+ : `MOD${index + 1}`;
58
+ const anyOneChildren = [];
59
+ if (anyOneSchema.properties !== undefined) {
60
+ anyOneChildren.push(createProperties(anyOneSchema));
61
+ }
62
+ if (anyOneSchema.allOf !== undefined) {
63
+ anyOneChildren.push(createNodes(anyOneSchema));
64
+ }
65
+ if (anyOneSchema.items !== undefined) {
66
+ anyOneChildren.push(createItems(anyOneSchema));
67
+ }
68
+ if (anyOneSchema.type === "string" ||
69
+ anyOneSchema.type === "number" ||
70
+ anyOneSchema.type === "integer" ||
71
+ anyOneSchema.type === "boolean") {
72
+ anyOneChildren.push(createNodes(anyOneSchema));
73
+ }
74
+ if (anyOneChildren.length) {
75
+ return (0, utils_1.create)("TabItem", {
76
+ label: label,
77
+ value: `${index}-item-properties`,
78
+ children: anyOneChildren,
79
+ });
80
+ }
81
+ return undefined;
82
+ }),
83
+ }),
84
+ ],
85
+ }),
86
+ ],
87
+ });
88
+ }
89
+ function createProperties(schema) {
90
+ const discriminator = schema.discriminator;
91
+ return Object.entries(schema.properties).map(([key, val]) => createEdges({
92
+ name: key,
93
+ schema: val,
94
+ required: Array.isArray(schema.required)
95
+ ? schema.required.includes(key)
96
+ : false,
97
+ discriminator,
98
+ }));
99
+ }
100
+ function createAdditionalProperties(schema) {
101
+ // TODO?:
102
+ // {
103
+ // description: 'Integration configuration. See \n' +
104
+ // '[Integration Configurations](https://prisma.pan.dev/api/cloud/api-integration-config/).\n',
105
+ // example: { webhookUrl: 'https://hooks.slack.com/abcdef' },
106
+ // externalDocs: { url: 'https://prisma.pan.dev/api/cloud/api-integration-config' },
107
+ // type: 'object'
108
+ // }
109
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
110
+ // TODO?:
111
+ // {
112
+ // items: {
113
+ // properties: {
114
+ // aliasField: [Object],
115
+ // displayName: [Object],
116
+ // fieldName: [Object],
117
+ // maxLength: [Object],
118
+ // options: [Object],
119
+ // redlockMapping: [Object],
120
+ // required: [Object],
121
+ // type: [Object],
122
+ // typeaheadUri: [Object],
123
+ // value: [Object]
124
+ // },
125
+ // type: 'object'
126
+ // },
127
+ // type: 'array'
128
+ // }
129
+ if (((_a = schema.additionalProperties) === null || _a === void 0 ? void 0 : _a.type) === "string" ||
130
+ ((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "object" ||
131
+ ((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "boolean" ||
132
+ ((_d = schema.additionalProperties) === null || _d === void 0 ? void 0 : _d.type) === "integer" ||
133
+ ((_e = schema.additionalProperties) === null || _e === void 0 ? void 0 : _e.type) === "number") {
134
+ const type = (_f = schema.additionalProperties) === null || _f === void 0 ? void 0 : _f.type;
135
+ const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
136
+ if (additionalProperties !== undefined) {
137
+ const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
138
+ const format = (_l = (_k = schema.additionalProperties) === null || _k === void 0 ? void 0 : _k.additionalProperties) === null || _l === void 0 ? void 0 : _l.format;
139
+ return (0, utils_1.create)("li", {
140
+ children: (0, utils_1.create)("div", {
141
+ children: [
142
+ (0, utils_1.create)("code", { children: `property name*` }),
143
+ (0, utils_1.guard)(type, (type) => (0, utils_1.create)("span", {
144
+ style: { opacity: "0.6" },
145
+ children: ` ${type}`,
146
+ })),
147
+ (0, utils_1.guard)(format, (format) => (0, utils_1.create)("span", {
148
+ style: { opacity: "0.6" },
149
+ children: ` (${format})`,
150
+ })),
151
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
152
+ style: { marginTop: "var(--ifm-table-cell-padding)" },
153
+ children: (0, createDescription_1.createDescription)(message),
154
+ })),
155
+ ],
156
+ }),
157
+ });
158
+ }
159
+ return (0, utils_1.create)("li", {
160
+ children: (0, utils_1.create)("div", {
161
+ children: [
162
+ (0, utils_1.create)("code", { children: `property name*` }),
163
+ (0, utils_1.guard)(type, (type) => (0, utils_1.create)("span", {
164
+ style: { opacity: "0.6" },
165
+ children: ` ${type}`,
166
+ })),
167
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
168
+ style: { marginTop: "var(--ifm-table-cell-padding)" },
169
+ children: (0, createDescription_1.createDescription)(message),
170
+ })),
171
+ ],
172
+ }),
173
+ });
174
+ }
175
+ return Object.entries(schema.additionalProperties).map(([key, val]) => createEdges({
176
+ name: key,
177
+ schema: val,
178
+ required: Array.isArray(schema.required)
179
+ ? schema.required.includes(key)
180
+ : false,
181
+ }));
182
+ }
183
+ // TODO: figure out how to handle array of objects
184
+ function createItems(schema) {
185
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
186
+ if (((_a = schema.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
187
+ return createProperties(schema.items);
188
+ }
189
+ if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.additionalProperties) !== undefined) {
190
+ return createAdditionalProperties(schema.items);
191
+ }
192
+ 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) {
193
+ return createAnyOneOf(schema.items);
194
+ }
195
+ if (((_e = schema.items) === null || _e === void 0 ? void 0 : _e.allOf) !== undefined) {
196
+ // TODO: figure out if and how we should pass merged required array
197
+ const { mergedSchemas, } = mergeAllOf((_f = schema.items) === null || _f === void 0 ? void 0 : _f.allOf);
198
+ // Handles combo anyOf/oneOf + properties
199
+ if ((mergedSchemas.oneOf !== undefined ||
200
+ mergedSchemas.anyOf !== undefined) &&
201
+ mergedSchemas.properties) {
202
+ return (0, utils_1.create)("div", {
203
+ children: [
204
+ createAnyOneOf(mergedSchemas),
205
+ createProperties(mergedSchemas),
206
+ ],
207
+ });
208
+ }
209
+ // Handles only anyOf/oneOf
210
+ if (mergedSchemas.oneOf !== undefined ||
211
+ mergedSchemas.anyOf !== undefined) {
212
+ return (0, utils_1.create)("div", {
213
+ children: [
214
+ createAnyOneOf(mergedSchemas),
215
+ createProperties(mergedSchemas),
216
+ ],
217
+ });
218
+ }
219
+ }
220
+ if (((_g = schema.items) === null || _g === void 0 ? void 0 : _g.type) === "string" ||
221
+ ((_h = schema.items) === null || _h === void 0 ? void 0 : _h.type) === "number" ||
222
+ ((_j = schema.items) === null || _j === void 0 ? void 0 : _j.type) === "integer" ||
223
+ ((_k = schema.items) === null || _k === void 0 ? void 0 : _k.type) === "boolean") {
224
+ return createNodes(schema.items);
225
+ }
226
+ // TODO: clean this up or eliminate it?
227
+ return Object.entries(schema.items).map(([key, val]) => createEdges({
228
+ name: key,
229
+ schema: val,
230
+ required: Array.isArray(schema.required)
231
+ ? schema.required.includes(key)
232
+ : false,
233
+ }));
234
+ }
235
+ /**
236
+ * For handling discriminators that do not map to a same-level property
237
+ */
238
+ function createDiscriminator(schema) {
239
+ var _a;
240
+ const discriminator = schema.discriminator;
241
+ const propertyName = discriminator === null || discriminator === void 0 ? void 0 : discriminator.propertyName;
242
+ const propertyType = "string"; // should always be string
243
+ const mapping = discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping;
244
+ // Explicit mapping is required since we can't support implicit
245
+ if (mapping === undefined) {
246
+ return undefined;
247
+ }
248
+ // Attempt to get the property description we want to display
249
+ // TODO: how to make it predictable when handling allOf
250
+ let propertyDescription;
251
+ const firstMappingSchema = mapping[Object.keys(mapping)[0]];
252
+ if (firstMappingSchema.properties !== undefined) {
253
+ propertyDescription =
254
+ firstMappingSchema.properties[propertyName].description;
255
+ }
256
+ if (firstMappingSchema.allOf !== undefined) {
257
+ const { mergedSchemas } = mergeAllOf(firstMappingSchema.allOf);
258
+ if (mergedSchemas.properties !== undefined) {
259
+ propertyDescription =
260
+ (_a = mergedSchemas.properties[propertyName]) === null || _a === void 0 ? void 0 : _a.description;
261
+ }
262
+ }
263
+ if (propertyDescription === undefined) {
264
+ if (schema.properties !== undefined &&
265
+ schema.properties[propertyName] !== undefined) {
266
+ propertyDescription = schema.properties[propertyName].description;
267
+ }
268
+ }
269
+ return (0, utils_1.create)("div", {
270
+ className: "discriminatorItem",
271
+ children: (0, utils_1.create)("div", {
272
+ children: [
273
+ (0, utils_1.create)("strong", {
274
+ style: { paddingLeft: "1rem" },
275
+ children: propertyName,
276
+ }),
277
+ (0, utils_1.guard)(propertyType, (name) => (0, utils_1.create)("span", {
278
+ style: { opacity: "0.6" },
279
+ children: ` ${propertyType}`,
280
+ })),
281
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.discriminator), (message) => (0, utils_1.create)("div", {
282
+ style: {
283
+ paddingLeft: "1rem",
284
+ },
285
+ children: (0, createDescription_1.createDescription)(message),
286
+ })),
287
+ (0, utils_1.guard)(propertyDescription, (description) => (0, utils_1.create)("div", {
288
+ style: {
289
+ paddingLeft: "1rem",
290
+ },
291
+ children: (0, createDescription_1.createDescription)(description),
292
+ })),
293
+ (0, utils_1.create)("DiscriminatorTabs", {
294
+ children: Object.keys(mapping).map((key, index) => {
295
+ if (mapping[key].allOf !== undefined) {
296
+ const { mergedSchemas } = mergeAllOf(mapping[key].allOf);
297
+ // Cleanup duplicate property from mapping schema
298
+ delete mergedSchemas.properties[propertyName];
299
+ mapping[key] = mergedSchemas;
300
+ }
301
+ if (mapping[key].properties !== undefined) {
302
+ // Cleanup duplicate property from mapping schema
303
+ delete mapping[key].properties[propertyName];
304
+ }
305
+ const label = key;
306
+ return (0, utils_1.create)("TabItem", {
307
+ label: label,
308
+ value: `${index}-item-discriminator`,
309
+ children: [
310
+ (0, utils_1.create)("div", {
311
+ style: { marginLeft: "-4px" },
312
+ children: createNodes(mapping[key]),
313
+ }),
314
+ ],
315
+ });
316
+ }),
317
+ }),
318
+ ],
319
+ }),
320
+ });
321
+ }
322
+ function createDetailsNode(name, schemaName, schema, required) {
323
+ return (0, utils_1.create)("SchemaItem", {
324
+ collapsible: true,
325
+ className: "schemaItem",
326
+ children: [
327
+ (0, createDetails_1.createDetails)({
328
+ children: [
329
+ (0, createDetailsSummary_1.createDetailsSummary)({
330
+ children: [
331
+ (0, utils_1.create)("strong", { children: name }),
332
+ (0, utils_1.create)("span", {
333
+ style: { opacity: "0.6" },
334
+ children: ` ${schemaName}`,
335
+ }),
336
+ (0, utils_1.guard)(schema.required && schema.required === true, () => [
337
+ (0, utils_1.create)("strong", {
338
+ style: {
339
+ fontSize: "var(--ifm-code-font-size)",
340
+ color: "var(--openapi-required)",
341
+ },
342
+ children: " required",
343
+ }),
344
+ ]),
345
+ ],
346
+ }),
347
+ (0, utils_1.create)("div", {
348
+ style: { marginLeft: "1rem" },
349
+ children: [
350
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
351
+ style: { marginTop: ".5rem", marginBottom: ".5rem" },
352
+ children: (0, createDescription_1.createDescription)(message),
353
+ })),
354
+ (0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
355
+ style: { marginTop: ".5rem", marginBottom: ".5rem" },
356
+ children: (0, createDescription_1.createDescription)(description),
357
+ })),
358
+ createNodes(schema),
359
+ ],
360
+ }),
361
+ ],
362
+ }),
363
+ ],
364
+ });
365
+ }
366
+ /**
367
+ * For handling discriminators that map to a same-level property (like 'petType').
368
+ * Note: These should only be encountered while iterating through properties.
369
+ */
370
+ function createPropertyDiscriminator(name, schemaName, schema, discriminator, required) {
371
+ if (schema === undefined) {
372
+ return undefined;
373
+ }
374
+ if (discriminator.mapping === undefined) {
375
+ return undefined;
376
+ }
377
+ return (0, utils_1.create)("div", {
378
+ className: "discriminatorItem",
379
+ children: (0, utils_1.create)("div", {
380
+ children: [
381
+ (0, utils_1.create)("strong", { style: { paddingLeft: "1rem" }, children: name }),
382
+ (0, utils_1.guard)(schemaName, (name) => (0, utils_1.create)("span", {
383
+ style: { opacity: "0.6" },
384
+ children: ` ${schemaName}`,
385
+ })),
386
+ (0, utils_1.guard)(required, () => [
387
+ (0, utils_1.create)("strong", {
388
+ style: {
389
+ fontSize: "var(--ifm-code-font-size)",
390
+ color: "var(--openapi-required)",
391
+ },
392
+ children: " required",
393
+ }),
394
+ ]),
395
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
396
+ style: {
397
+ paddingLeft: "1rem",
398
+ },
399
+ children: (0, createDescription_1.createDescription)(message),
400
+ })),
401
+ (0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
402
+ style: {
403
+ paddingLeft: "1rem",
404
+ },
405
+ children: (0, createDescription_1.createDescription)(description),
406
+ })),
407
+ (0, utils_1.create)("DiscriminatorTabs", {
408
+ children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
409
+ const label = key;
410
+ return (0, utils_1.create)("TabItem", {
411
+ label: label,
412
+ value: `${index}-item-discriminator`,
413
+ children: [
414
+ (0, utils_1.create)("div", {
415
+ style: { marginLeft: "-4px" },
416
+ children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
417
+ }),
418
+ ],
419
+ });
420
+ }),
421
+ }),
422
+ ],
423
+ }),
424
+ });
425
+ }
426
+ /**
427
+ * Creates the edges or "leaves" of a schema tree. Edges can branch into sub-nodes with createDetails().
428
+ */
429
+ function createEdges({ name, schema, required, discriminator, }) {
430
+ var _a, _b;
431
+ const schemaName = (0, schema_1.getSchemaName)(schema);
432
+ if (discriminator !== undefined && discriminator.propertyName === name) {
433
+ return createPropertyDiscriminator(name, "string", schema, discriminator, required);
434
+ }
435
+ if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
436
+ return createDetailsNode(name, schemaName, schema, required);
437
+ }
438
+ if (schema.allOf !== undefined) {
439
+ const { mergedSchemas, required, } = mergeAllOf(schema.allOf);
440
+ const mergedSchemaName = (0, schema_1.getSchemaName)(mergedSchemas);
441
+ if (mergedSchemas.oneOf !== undefined ||
442
+ mergedSchemas.anyOf !== undefined) {
443
+ return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
444
+ }
445
+ if (mergedSchemas.properties !== undefined) {
446
+ return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
447
+ }
448
+ if (mergedSchemas.additionalProperties !== undefined) {
449
+ return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
450
+ }
451
+ // array of objects
452
+ if (((_a = mergedSchemas.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
453
+ return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
454
+ }
455
+ if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
456
+ return undefined;
457
+ }
458
+ return (0, utils_1.create)("SchemaItem", {
459
+ collapsible: false,
460
+ name,
461
+ required: false,
462
+ schemaDescription: mergedSchemas.description,
463
+ schemaName: schemaName,
464
+ qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
465
+ defaultValue: mergedSchemas.default,
466
+ });
467
+ }
468
+ if (schema.properties !== undefined) {
469
+ return createDetailsNode(name, schemaName, schema, required);
470
+ }
471
+ if (schema.additionalProperties !== undefined) {
472
+ return createDetailsNode(name, schemaName, schema, required);
473
+ }
474
+ // array of objects
475
+ if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.properties) !== undefined) {
476
+ return createDetailsNode(name, schemaName, schema, required);
477
+ }
478
+ if (schema.writeOnly && schema.writeOnly === true) {
479
+ return undefined;
480
+ }
481
+ // primitives and array of non-objects
482
+ return (0, utils_1.create)("SchemaItem", {
483
+ collapsible: false,
484
+ name,
485
+ required: false,
486
+ schemaDescription: schema.description,
487
+ schemaName: schemaName,
488
+ qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
489
+ defaultValue: schema.default,
490
+ });
491
+ }
492
+ /**
493
+ * Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
494
+ */
495
+ function createNodes(schema) {
496
+ if (schema.discriminator !== undefined) {
497
+ return createDiscriminator(schema);
498
+ }
499
+ if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
500
+ return createAnyOneOf(schema);
501
+ }
502
+ if (schema.allOf !== undefined) {
503
+ const { mergedSchemas } = mergeAllOf(schema.allOf);
504
+ // allOf seems to always result in properties
505
+ if (mergedSchemas.properties !== undefined) {
506
+ return createProperties(mergedSchemas);
507
+ }
508
+ }
509
+ if (schema.properties !== undefined) {
510
+ return createProperties(schema);
511
+ }
512
+ // Could be set to false to just check if evals to true
513
+ if (schema.additionalProperties) {
514
+ return createAdditionalProperties(schema);
515
+ }
516
+ // TODO: figure out how to handle array of objects
517
+ if (schema.items !== undefined) {
518
+ return createItems(schema);
519
+ }
520
+ // primitive
521
+ if (schema.type !== undefined) {
522
+ return (0, utils_1.create)("li", {
523
+ children: (0, utils_1.create)("div", {
524
+ children: [
525
+ (0, utils_1.create)("strong", { children: schema.type }),
526
+ (0, utils_1.guard)(schema.format, (format) => (0, utils_1.create)("span", {
527
+ style: { opacity: "0.6" },
528
+ children: ` ${format}`,
529
+ })),
530
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
531
+ style: { marginTop: "var(--ifm-table-cell-padding)" },
532
+ children: (0, createDescription_1.createDescription)(message),
533
+ })),
534
+ (0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
535
+ style: { marginTop: "var(--ifm-table-cell-padding)" },
536
+ children: (0, createDescription_1.createDescription)(description),
537
+ })),
538
+ ],
539
+ }),
540
+ });
541
+ }
542
+ // Unknown node/schema type should return undefined
543
+ // So far, haven't seen this hit in testing
544
+ return undefined;
545
+ }
546
+ function createResponseSchema({ title, body, ...rest }) {
547
+ if (body === undefined ||
548
+ body.content === undefined ||
549
+ Object.keys(body).length === 0 ||
550
+ Object.keys(body.content).length === 0) {
551
+ return undefined;
552
+ }
553
+ // Get all MIME types, including vendor-specific
554
+ const mimeTypes = Object.keys(body.content);
555
+ if (mimeTypes && mimeTypes.length) {
556
+ return (0, utils_1.create)("MimeTabs", {
557
+ groupId: "mime-type",
558
+ children: mimeTypes.map((mimeType) => {
559
+ const responseExamples = body.content[mimeType].examples;
560
+ const responseExample = body.content[mimeType].example;
561
+ const firstBody = body.content[mimeType].schema;
562
+ if (firstBody === undefined &&
563
+ responseExample === undefined &&
564
+ responseExamples === undefined) {
565
+ return undefined;
566
+ }
567
+ if ((firstBody === null || firstBody === void 0 ? void 0 : firstBody.properties) !== undefined) {
568
+ if (Object.keys(firstBody === null || firstBody === void 0 ? void 0 : firstBody.properties).length === 0) {
569
+ return undefined;
570
+ }
571
+ }
572
+ return (0, utils_1.create)("TabItem", {
573
+ label: `${mimeType}`,
574
+ value: `${mimeType}`,
575
+ children: [
576
+ (0, utils_1.create)("SchemaTabs", {
577
+ groupId: "schema-tabs",
578
+ children: [
579
+ firstBody &&
580
+ (0, utils_1.create)("TabTtem", {
581
+ label: `${title}`,
582
+ value: `${title}`,
583
+ children: [
584
+ (0, createDetails_1.createDetails)({
585
+ "data-collapsed": false,
586
+ open: true,
587
+ ...rest,
588
+ children: [
589
+ (0, createDetailsSummary_1.createDetailsSummary)({
590
+ style: { textAlign: "left" },
591
+ children: [
592
+ (0, utils_1.create)("strong", { children: `${title}` }),
593
+ (0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
594
+ style: { opacity: "0.6" },
595
+ children: ` array`,
596
+ })),
597
+ (0, utils_1.guard)(body.required && body.required === true, () => [
598
+ (0, utils_1.create)("strong", {
599
+ style: {
600
+ fontSize: "var(--ifm-code-font-size)",
601
+ color: "var(--openapi-required)",
602
+ },
603
+ children: " required",
604
+ }),
605
+ ]),
606
+ ],
607
+ }),
608
+ (0, utils_1.create)("div", {
609
+ style: { textAlign: "left", marginLeft: "1rem" },
610
+ children: [
611
+ (0, utils_1.guard)(body.description, () => [
612
+ (0, utils_1.create)("div", {
613
+ style: {
614
+ marginTop: "1rem",
615
+ marginBottom: "1rem",
616
+ },
617
+ children: (0, createDescription_1.createDescription)(body.description),
618
+ }),
619
+ ]),
620
+ ],
621
+ }),
622
+ (0, utils_1.create)("ul", {
623
+ style: { marginLeft: "1rem" },
624
+ children: createNodes(firstBody),
625
+ }),
626
+ ],
627
+ }),
628
+ ],
629
+ }),
630
+ responseExamples && (0, createStatusCodes_1.createResponseExamples)(responseExamples),
631
+ responseExample && (0, createStatusCodes_1.createResponseExample)(responseExample),
632
+ ],
633
+ }),
634
+ ],
635
+ });
636
+ }),
637
+ });
638
+ }
639
+ return undefined;
640
+ }
641
+ exports.createResponseSchema = createResponseSchema;
@@ -7,7 +7,7 @@ interface Props {
7
7
  [key: string]: MediaTypeObject;
8
8
  };
9
9
  description?: string;
10
- required?: boolean;
10
+ required?: string[] | boolean;
11
11
  };
12
12
  }
13
13
  export declare function createSchemaDetails({ title, body, ...rest }: Props): string | undefined;