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,680 @@
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.createRequestSchema = exports.mergeAllOf = void 0;
10
+ const createDescription_1 = require("./createDescription");
11
+ const createDetails_1 = require("./createDetails");
12
+ const createDetailsSummary_1 = require("./createDetailsSummary");
13
+ const schema_1 = require("./schema");
14
+ const utils_1 = require("./utils");
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, {
21
+ resolvers: {
22
+ readOnly: function () {
23
+ return true;
24
+ },
25
+ example: function () {
26
+ return true;
27
+ },
28
+ },
29
+ });
30
+ const required = allOf.reduce((acc, cur) => {
31
+ if (Array.isArray(cur.required)) {
32
+ const next = [...acc, ...cur.required];
33
+ return next;
34
+ }
35
+ return acc;
36
+ }, []);
37
+ return { mergedSchemas, required };
38
+ }
39
+ exports.mergeAllOf = mergeAllOf;
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.readOnly && mergedSchemas.readOnly === true) {
456
+ return undefined;
457
+ }
458
+ return (0, utils_1.create)("SchemaItem", {
459
+ collapsible: false,
460
+ name,
461
+ required: Array.isArray(required) ? required.includes(name) : required,
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.readOnly && schema.readOnly === 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: Array.isArray(required) ? required.includes(name) : required,
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
+ if (schema.additionalProperties !== undefined) {
513
+ return createAdditionalProperties(schema);
514
+ }
515
+ // TODO: figure out how to handle array of objects
516
+ if (schema.items !== undefined) {
517
+ return createItems(schema);
518
+ }
519
+ // primitive
520
+ if (schema.type !== undefined) {
521
+ return (0, utils_1.create)("li", {
522
+ children: (0, utils_1.create)("div", {
523
+ children: [
524
+ (0, utils_1.create)("strong", { children: schema.type }),
525
+ (0, utils_1.guard)(schema.format, (format) => (0, utils_1.create)("span", {
526
+ style: { opacity: "0.6" },
527
+ children: ` ${format}`,
528
+ })),
529
+ (0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema), (message) => (0, utils_1.create)("div", {
530
+ style: { marginTop: "var(--ifm-table-cell-padding)" },
531
+ children: (0, createDescription_1.createDescription)(message),
532
+ })),
533
+ (0, utils_1.guard)(schema.description, (description) => (0, utils_1.create)("div", {
534
+ style: { marginTop: "var(--ifm-table-cell-padding)" },
535
+ children: (0, createDescription_1.createDescription)(description),
536
+ })),
537
+ ],
538
+ }),
539
+ });
540
+ }
541
+ // Unknown node/schema type should return undefined
542
+ // So far, haven't seen this hit in testing
543
+ return undefined;
544
+ }
545
+ function createRequestSchema({ title, body, ...rest }) {
546
+ if (body === undefined ||
547
+ body.content === undefined ||
548
+ Object.keys(body).length === 0 ||
549
+ Object.keys(body.content).length === 0) {
550
+ return undefined;
551
+ }
552
+ // Get all MIME types, including vendor-specific
553
+ const mimeTypes = Object.keys(body.content);
554
+ if (mimeTypes && mimeTypes.length > 1) {
555
+ return (0, utils_1.create)("MimeTabs", {
556
+ groupId: "mime-type",
557
+ children: mimeTypes.map((mimeType) => {
558
+ const firstBody = body.content[mimeType].schema;
559
+ if (firstBody === undefined) {
560
+ return undefined;
561
+ }
562
+ if (firstBody.properties !== undefined) {
563
+ if (Object.keys(firstBody.properties).length === 0) {
564
+ return undefined;
565
+ }
566
+ }
567
+ return (0, utils_1.create)("TabItem", {
568
+ label: mimeType,
569
+ value: `${mimeType}`,
570
+ children: [
571
+ (0, createDetails_1.createDetails)({
572
+ "data-collapsed": false,
573
+ open: true,
574
+ ...rest,
575
+ children: [
576
+ (0, createDetailsSummary_1.createDetailsSummary)({
577
+ style: { textAlign: "left" },
578
+ children: [
579
+ (0, utils_1.create)("strong", { children: `${title}` }),
580
+ (0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
581
+ style: { opacity: "0.6" },
582
+ children: ` array`,
583
+ })),
584
+ (0, utils_1.guard)(body.required && body.required === true, () => [
585
+ (0, utils_1.create)("strong", {
586
+ style: {
587
+ fontSize: "var(--ifm-code-font-size)",
588
+ color: "var(--openapi-required)",
589
+ },
590
+ children: " required",
591
+ }),
592
+ ]),
593
+ ],
594
+ }),
595
+ (0, utils_1.create)("div", {
596
+ style: { textAlign: "left", marginLeft: "1rem" },
597
+ children: [
598
+ (0, utils_1.guard)(body.description, () => [
599
+ (0, utils_1.create)("div", {
600
+ style: { marginTop: "1rem", marginBottom: "1rem" },
601
+ children: (0, createDescription_1.createDescription)(body.description),
602
+ }),
603
+ ]),
604
+ ],
605
+ }),
606
+ (0, utils_1.create)("ul", {
607
+ style: { marginLeft: "1rem" },
608
+ children: createNodes(firstBody),
609
+ }),
610
+ ],
611
+ }),
612
+ ],
613
+ });
614
+ }),
615
+ });
616
+ }
617
+ const randomFirstKey = Object.keys(body.content)[0];
618
+ const firstBody = body.content[randomFirstKey].schema;
619
+ if (firstBody === undefined) {
620
+ return undefined;
621
+ }
622
+ // we don't show the table if there is no properties to show
623
+ if (firstBody.properties !== undefined) {
624
+ if (Object.keys(firstBody.properties).length === 0) {
625
+ return undefined;
626
+ }
627
+ }
628
+ return (0, utils_1.create)("MimeTabs", {
629
+ children: [
630
+ (0, utils_1.create)("TabItem", {
631
+ label: randomFirstKey,
632
+ value: `${randomFirstKey}-schema`,
633
+ children: [
634
+ (0, createDetails_1.createDetails)({
635
+ "data-collapsed": false,
636
+ open: true,
637
+ ...rest,
638
+ children: [
639
+ (0, createDetailsSummary_1.createDetailsSummary)({
640
+ style: { textAlign: "left" },
641
+ children: [
642
+ (0, utils_1.create)("strong", { children: `${title}` }),
643
+ (0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
644
+ style: { opacity: "0.6" },
645
+ children: ` array`,
646
+ })),
647
+ (0, utils_1.guard)(body.required, () => [
648
+ (0, utils_1.create)("strong", {
649
+ style: {
650
+ fontSize: "var(--ifm-code-font-size)",
651
+ color: "var(--openapi-required)",
652
+ },
653
+ children: " required",
654
+ }),
655
+ ]),
656
+ ],
657
+ }),
658
+ (0, utils_1.create)("div", {
659
+ style: { textAlign: "left", marginLeft: "1rem" },
660
+ children: [
661
+ (0, utils_1.guard)(body.description, () => [
662
+ (0, utils_1.create)("div", {
663
+ style: { marginTop: "1rem", marginBottom: "1rem" },
664
+ children: (0, createDescription_1.createDescription)(body.description),
665
+ }),
666
+ ]),
667
+ ],
668
+ }),
669
+ (0, utils_1.create)("ul", {
670
+ style: { marginLeft: "1rem" },
671
+ children: createNodes(firstBody),
672
+ }),
673
+ ],
674
+ }),
675
+ ],
676
+ }),
677
+ ],
678
+ });
679
+ }
680
+ exports.createRequestSchema = createRequestSchema;