docusaurus-plugin-openapi-docs 0.0.0-431 → 0.0.0-433

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.
@@ -235,90 +235,100 @@ function createItems(schema) {
235
235
  /**
236
236
  * For handling discriminators that do not map to a same-level property
237
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
- }
238
+ // function createDiscriminator(schema: SchemaObject) {
239
+ // const discriminator = schema.discriminator;
240
+ // const propertyName = discriminator?.propertyName;
241
+ // const propertyType = "string"; // should always be string
242
+ // const mapping: any = discriminator?.mapping;
243
+ // // Explicit mapping is required since we can't support implicit
244
+ // if (mapping === undefined) {
245
+ // return undefined;
246
+ // }
247
+ // // Attempt to get the property description we want to display
248
+ // // TODO: how to make it predictable when handling allOf
249
+ // let propertyDescription;
250
+ // const firstMappingSchema = mapping[Object.keys(mapping)[0]];
251
+ // if (firstMappingSchema.properties !== undefined) {
252
+ // propertyDescription =
253
+ // firstMappingSchema.properties![propertyName!].description;
254
+ // }
255
+ // if (firstMappingSchema.allOf !== undefined) {
256
+ // const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
257
+ // firstMappingSchema.allOf
258
+ // );
259
+ // if (mergedSchemas.properties !== undefined) {
260
+ // propertyDescription =
261
+ // mergedSchemas.properties[propertyName!]?.description;
262
+ // }
263
+ // }
264
+ // if (propertyDescription === undefined) {
265
+ // if (
266
+ // schema.properties !== undefined &&
267
+ // schema.properties![propertyName!] !== undefined
268
+ // ) {
269
+ // propertyDescription = schema.properties![propertyName!].description;
270
+ // }
271
+ // }
272
+ // return create("div", {
273
+ // className: "discriminatorItem",
274
+ // children: create("div", {
275
+ // children: [
276
+ // create("strong", {
277
+ // style: { paddingLeft: "1rem" },
278
+ // children: propertyName,
279
+ // }),
280
+ // guard(propertyType, (name) =>
281
+ // create("span", {
282
+ // style: { opacity: "0.6" },
283
+ // children: ` ${propertyType}`,
284
+ // })
285
+ // ),
286
+ // guard(getQualifierMessage(schema.discriminator as any), (message) =>
287
+ // create("div", {
288
+ // style: {
289
+ // paddingLeft: "1rem",
290
+ // },
291
+ // children: createDescription(message),
292
+ // })
293
+ // ),
294
+ // guard(propertyDescription, (description) =>
295
+ // create("div", {
296
+ // style: {
297
+ // paddingLeft: "1rem",
298
+ // },
299
+ // children: createDescription(description),
300
+ // })
301
+ // ),
302
+ // create("DiscriminatorTabs", {
303
+ // children: Object.keys(mapping!).map((key, index) => {
304
+ // if (mapping[key].allOf !== undefined) {
305
+ // const { mergedSchemas }: { mergedSchemas: SchemaObject } =
306
+ // mergeAllOf(mapping[key].allOf);
307
+ // // Cleanup duplicate property from mapping schema
308
+ // delete mergedSchemas.properties![propertyName!];
309
+ // mapping[key] = mergedSchemas;
310
+ // }
311
+ // if (mapping[key].properties !== undefined) {
312
+ // // Cleanup duplicate property from mapping schema
313
+ // delete mapping[key].properties![propertyName!];
314
+ // }
315
+ // const label = key;
316
+ // return create("TabItem", {
317
+ // label: label,
318
+ // value: `${index}-item-discriminator`,
319
+ // children: [
320
+ // create("div", {
321
+ // style: { marginLeft: "-4px" },
322
+ // children: createNodes(mapping[key]),
323
+ // }),
324
+ // ],
325
+ // });
326
+ // }),
327
+ // }),
328
+ // ],
329
+ // }),
330
+ // });
331
+ // }
322
332
  function createDetailsNode(name, schemaName, schema, required) {
323
333
  return (0, utils_1.create)("SchemaItem", {
324
334
  collapsible: true,
@@ -493,9 +503,9 @@ function createEdges({ name, schema, required, discriminator, }) {
493
503
  * Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
494
504
  */
495
505
  function createNodes(schema) {
496
- if (schema.discriminator !== undefined) {
497
- return createDiscriminator(schema);
498
- }
506
+ // if (schema.discriminator !== undefined) {
507
+ // return createDiscriminator(schema);
508
+ // }
499
509
  if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
500
510
  return createAnyOneOf(schema);
501
511
  }
@@ -235,90 +235,100 @@ function createItems(schema) {
235
235
  /**
236
236
  * For handling discriminators that do not map to a same-level property
237
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
- }
238
+ // function createDiscriminator(schema: SchemaObject) {
239
+ // const discriminator = schema.discriminator;
240
+ // const propertyName = discriminator?.propertyName;
241
+ // const propertyType = "string"; // should always be string
242
+ // const mapping: any = discriminator?.mapping;
243
+ // // Explicit mapping is required since we can't support implicit
244
+ // if (mapping === undefined) {
245
+ // return undefined;
246
+ // }
247
+ // // Attempt to get the property description we want to display
248
+ // // TODO: how to make it predictable when handling allOf
249
+ // let propertyDescription;
250
+ // const firstMappingSchema = mapping[Object.keys(mapping)[0]];
251
+ // if (firstMappingSchema.properties !== undefined) {
252
+ // propertyDescription =
253
+ // firstMappingSchema.properties![propertyName!].description;
254
+ // }
255
+ // if (firstMappingSchema.allOf !== undefined) {
256
+ // const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
257
+ // firstMappingSchema.allOf
258
+ // );
259
+ // if (mergedSchemas.properties !== undefined) {
260
+ // propertyDescription =
261
+ // mergedSchemas.properties[propertyName!]?.description;
262
+ // }
263
+ // }
264
+ // if (propertyDescription === undefined) {
265
+ // if (
266
+ // schema.properties !== undefined &&
267
+ // schema.properties![propertyName!] !== undefined
268
+ // ) {
269
+ // propertyDescription = schema.properties![propertyName!].description;
270
+ // }
271
+ // }
272
+ // return create("div", {
273
+ // className: "discriminatorItem",
274
+ // children: create("div", {
275
+ // children: [
276
+ // create("strong", {
277
+ // style: { paddingLeft: "1rem" },
278
+ // children: propertyName,
279
+ // }),
280
+ // guard(propertyType, (name) =>
281
+ // create("span", {
282
+ // style: { opacity: "0.6" },
283
+ // children: ` ${propertyType}`,
284
+ // })
285
+ // ),
286
+ // guard(getQualifierMessage(schema.discriminator as any), (message) =>
287
+ // create("div", {
288
+ // style: {
289
+ // paddingLeft: "1rem",
290
+ // },
291
+ // children: createDescription(message),
292
+ // })
293
+ // ),
294
+ // guard(propertyDescription, (description) =>
295
+ // create("div", {
296
+ // style: {
297
+ // paddingLeft: "1rem",
298
+ // },
299
+ // children: createDescription(description),
300
+ // })
301
+ // ),
302
+ // create("DiscriminatorTabs", {
303
+ // children: Object.keys(mapping!).map((key, index) => {
304
+ // if (mapping[key].allOf !== undefined) {
305
+ // const { mergedSchemas }: { mergedSchemas: SchemaObject } =
306
+ // mergeAllOf(mapping[key].allOf);
307
+ // // Cleanup duplicate property from mapping schema
308
+ // delete mergedSchemas.properties![propertyName!];
309
+ // mapping[key] = mergedSchemas;
310
+ // }
311
+ // if (mapping[key].properties !== undefined) {
312
+ // // Cleanup duplicate property from mapping schema
313
+ // delete mapping[key].properties![propertyName!];
314
+ // }
315
+ // const label = key;
316
+ // return create("TabItem", {
317
+ // label: label,
318
+ // value: `${index}-item-discriminator`,
319
+ // children: [
320
+ // create("div", {
321
+ // style: { marginLeft: "-4px" },
322
+ // children: createNodes(mapping[key]),
323
+ // }),
324
+ // ],
325
+ // });
326
+ // }),
327
+ // }),
328
+ // ],
329
+ // }),
330
+ // });
331
+ // }
322
332
  function createDetailsNode(name, schemaName, schema, required) {
323
333
  return (0, utils_1.create)("SchemaItem", {
324
334
  collapsible: true,
@@ -493,9 +503,9 @@ function createEdges({ name, schema, required, discriminator, }) {
493
503
  * Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
494
504
  */
495
505
  function createNodes(schema) {
496
- if (schema.discriminator !== undefined) {
497
- return createDiscriminator(schema);
498
- }
506
+ // if (schema.discriminator !== undefined) {
507
+ // return createDiscriminator(schema);
508
+ // }
499
509
  if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
500
510
  return createAnyOneOf(schema);
501
511
  }
@@ -627,8 +637,11 @@ function createResponseSchema({ title, body, ...rest }) {
627
637
  }),
628
638
  ],
629
639
  }),
630
- responseExamples && (0, createStatusCodes_1.createResponseExamples)(responseExamples),
631
- responseExample && (0, createStatusCodes_1.createResponseExample)(responseExample),
640
+ firstBody && (0, createStatusCodes_1.createExampleFromSchema)(firstBody, mimeType),
641
+ responseExamples &&
642
+ (0, createStatusCodes_1.createResponseExamples)(responseExamples, mimeType),
643
+ responseExample &&
644
+ (0, createStatusCodes_1.createResponseExample)(responseExample, mimeType),
632
645
  ],
633
646
  }),
634
647
  ],
@@ -1,8 +1,10 @@
1
1
  import { ApiItem } from "../types";
2
+ export default function json2xml(o: any, tab: any): string;
2
3
  interface Props {
3
4
  responses: ApiItem["responses"];
4
5
  }
5
- export declare function createResponseExamples(responseExamples: any): string[];
6
- export declare function createResponseExample(responseExample: any): string;
6
+ export declare function createResponseExamples(responseExamples: any, mimeType: string): string[];
7
+ export declare function createResponseExample(responseExample: any, mimeType: string): string;
8
+ export declare function createExampleFromSchema(schema: any, mimeType: string): string | undefined;
7
9
  export declare function createStatusCodes({ responses }: Props): string | undefined;
8
10
  export {};
@@ -5,14 +5,62 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  * ========================================================================== */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createStatusCodes = exports.createResponseExample = exports.createResponseExamples = void 0;
12
+ exports.createStatusCodes = exports.createExampleFromSchema = exports.createResponseExample = exports.createResponseExamples = void 0;
13
+ const xml_formatter_1 = __importDefault(require("xml-formatter"));
14
+ const createResponseExample_1 = require("../openapi/createResponseExample");
10
15
  const createDescription_1 = require("./createDescription");
11
16
  const createDetails_1 = require("./createDetails");
12
17
  const createDetailsSummary_1 = require("./createDetailsSummary");
13
18
  const createResponseSchema_1 = require("./createResponseSchema");
14
19
  const utils_1 = require("./utils");
15
20
  const utils_2 = require("./utils");
21
+ function json2xml(o, tab) {
22
+ var toXml = function (v, name, ind) {
23
+ var xml = "";
24
+ if (v instanceof Array) {
25
+ for (var i = 0, n = v.length; i < n; i++)
26
+ xml += ind + toXml(v[i], name, ind + "\t") + "\n";
27
+ }
28
+ else if (typeof v == "object") {
29
+ var hasChild = false;
30
+ xml += ind + "<" + name;
31
+ for (var m in v) {
32
+ if (m.charAt(0) === "@")
33
+ xml += " " + m.substr(1) + '="' + v[m].toString() + '"';
34
+ else
35
+ hasChild = true;
36
+ }
37
+ xml += hasChild ? ">" : "/>";
38
+ if (hasChild) {
39
+ for (var m2 in v) {
40
+ if (m2 === "#text")
41
+ xml += v[m2];
42
+ else if (m2 === "#cdata")
43
+ xml += "<![CDATA[" + v[m2] + "]]>";
44
+ else if (m2.charAt(0) !== "@")
45
+ xml += toXml(v[m2], m2, ind + "\t");
46
+ }
47
+ xml +=
48
+ (xml.charAt(xml.length - 1) === "\n" ? ind : "") +
49
+ "</" +
50
+ name +
51
+ ">";
52
+ }
53
+ }
54
+ else {
55
+ xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">";
56
+ }
57
+ return xml;
58
+ }, xml = "";
59
+ for (var m3 in o)
60
+ xml += toXml(o[m3], m3, "");
61
+ return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
62
+ }
63
+ exports.default = json2xml;
16
64
  function createResponseHeaders(responseHeaders) {
17
65
  return (0, utils_2.guard)(responseHeaders, () => (0, utils_1.create)("ul", {
18
66
  style: { marginLeft: "1rem" },
@@ -53,7 +101,14 @@ function createResponseHeaders(responseHeaders) {
53
101
  ],
54
102
  }));
55
103
  }
56
- function createResponseExamples(responseExamples) {
104
+ function createResponseExamples(responseExamples, mimeType) {
105
+ let language = "shell";
106
+ if (mimeType.endsWith("json")) {
107
+ language = "json";
108
+ }
109
+ if (mimeType.endsWith("xml")) {
110
+ language = "xml";
111
+ }
57
112
  return Object.entries(responseExamples).map(([exampleName, exampleValue]) => {
58
113
  const camelToSpaceName = exampleName.replace(/([A-Z])/g, " $1");
59
114
  let finalFormattedName = camelToSpaceName.charAt(0).toUpperCase() + camelToSpaceName.slice(1);
@@ -64,6 +119,7 @@ function createResponseExamples(responseExamples) {
64
119
  children: [
65
120
  (0, utils_1.create)("ResponseSamples", {
66
121
  responseExample: JSON.stringify(exampleValue.value, null, 2),
122
+ language: language,
67
123
  }),
68
124
  ],
69
125
  });
@@ -74,13 +130,21 @@ function createResponseExamples(responseExamples) {
74
130
  children: [
75
131
  (0, utils_1.create)("ResponseSamples", {
76
132
  responseExample: exampleValue.value,
133
+ language: language,
77
134
  }),
78
135
  ],
79
136
  });
80
137
  });
81
138
  }
82
139
  exports.createResponseExamples = createResponseExamples;
83
- function createResponseExample(responseExample) {
140
+ function createResponseExample(responseExample, mimeType) {
141
+ let language = "shell";
142
+ if (mimeType.endsWith("json")) {
143
+ language = "json";
144
+ }
145
+ if (mimeType.endsWith("xml")) {
146
+ language = "xml";
147
+ }
84
148
  if (typeof responseExample === "object") {
85
149
  return (0, utils_1.create)("TabItem", {
86
150
  label: `Example`,
@@ -88,6 +152,7 @@ function createResponseExample(responseExample) {
88
152
  children: [
89
153
  (0, utils_1.create)("ResponseSamples", {
90
154
  responseExample: JSON.stringify(responseExample, null, 2),
155
+ language: language,
91
156
  }),
92
157
  ],
93
158
  });
@@ -98,11 +163,71 @@ function createResponseExample(responseExample) {
98
163
  children: [
99
164
  (0, utils_1.create)("ResponseSamples", {
100
165
  responseExample: responseExample,
166
+ language: language,
101
167
  }),
102
168
  ],
103
169
  });
104
170
  }
105
171
  exports.createResponseExample = createResponseExample;
172
+ function createExampleFromSchema(schema, mimeType) {
173
+ const responseExample = (0, createResponseExample_1.sampleResponseFromSchema)(schema);
174
+ if (mimeType.endsWith("xml")) {
175
+ let responseExampleObject;
176
+ try {
177
+ responseExampleObject = JSON.parse(JSON.stringify(responseExample));
178
+ }
179
+ catch {
180
+ return undefined;
181
+ }
182
+ if (typeof responseExampleObject === "object") {
183
+ let xmlExample;
184
+ try {
185
+ xmlExample = (0, xml_formatter_1.default)(json2xml(responseExampleObject, ""), {
186
+ indentation: " ",
187
+ lineSeparator: "\n",
188
+ collapseContent: true,
189
+ });
190
+ }
191
+ catch {
192
+ const xmlExampleWithRoot = { root: responseExampleObject };
193
+ try {
194
+ xmlExample = (0, xml_formatter_1.default)(json2xml(xmlExampleWithRoot, ""), {
195
+ indentation: " ",
196
+ lineSeparator: "\n",
197
+ collapseContent: true,
198
+ });
199
+ }
200
+ catch {
201
+ xmlExample = json2xml(responseExampleObject, "");
202
+ }
203
+ }
204
+ return (0, utils_1.create)("TabItem", {
205
+ label: `Example (from schema)`,
206
+ value: `Example (from schema)`,
207
+ children: [
208
+ (0, utils_1.create)("ResponseSamples", {
209
+ responseExample: xmlExample,
210
+ language: "xml",
211
+ }),
212
+ ],
213
+ });
214
+ }
215
+ }
216
+ if (typeof responseExample === "object") {
217
+ return (0, utils_1.create)("TabItem", {
218
+ label: `Example (from schema)`,
219
+ value: `Example (from schema)`,
220
+ children: [
221
+ (0, utils_1.create)("ResponseSamples", {
222
+ responseExample: JSON.stringify(responseExample, null, 2),
223
+ language: "json",
224
+ }),
225
+ ],
226
+ });
227
+ }
228
+ return undefined;
229
+ }
230
+ exports.createExampleFromSchema = createExampleFromSchema;
106
231
  function createStatusCodes({ responses }) {
107
232
  if (responses === undefined) {
108
233
  return undefined;
@@ -127,8 +252,8 @@ function createStatusCodes({ responses }) {
127
252
  }),
128
253
  responseHeaders &&
129
254
  (0, createDetails_1.createDetails)({
130
- "data-collaposed": false,
131
- open: true,
255
+ "data-collaposed": true,
256
+ open: false,
132
257
  style: { textAlign: "left", marginBottom: "1rem" },
133
258
  children: [
134
259
  (0, createDetailsSummary_1.createDetailsSummary)({
@@ -0,0 +1,2 @@
1
+ import { SchemaObject } from "./types";
2
+ export declare const sampleRequestFromSchema: (schema?: SchemaObject) => any;