docusaurus-plugin-openapi-docs 1.1.3 → 1.1.6

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.
@@ -7,8 +7,8 @@ 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
- export declare function createSchemaDetails({ title, body, ...rest }: Props): string | undefined;
13
+ export declare function createResponseSchema({ title, body, ...rest }: Props): string | undefined;
14
14
  export {};
@@ -6,10 +6,11 @@
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 = void 0;
9
+ exports.createResponseSchema = void 0;
10
10
  const createDescription_1 = require("./createDescription");
11
11
  const createDetails_1 = require("./createDetails");
12
12
  const createDetailsSummary_1 = require("./createDetailsSummary");
13
+ const createStatusCodes_1 = require("./createStatusCodes");
13
14
  const schema_1 = require("./schema");
14
15
  const utils_1 = require("./utils");
15
16
  const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
@@ -192,7 +193,8 @@ function createItems(schema) {
192
193
  return createAnyOneOf(schema.items);
193
194
  }
194
195
  if (((_e = schema.items) === null || _e === void 0 ? void 0 : _e.allOf) !== undefined) {
195
- const { mergedSchemas } = mergeAllOf((_f = schema.items) === null || _f === void 0 ? void 0 : _f.allOf);
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);
196
198
  // Handles combo anyOf/oneOf + properties
197
199
  if ((mergedSchemas.oneOf !== undefined ||
198
200
  mergedSchemas.anyOf !== undefined) &&
@@ -331,7 +333,7 @@ function createDetailsNode(name, schemaName, schema, required) {
331
333
  style: { opacity: "0.6" },
332
334
  children: ` ${schemaName}`,
333
335
  }),
334
- (0, utils_1.guard)(required, () => [
336
+ (0, utils_1.guard)(schema.required && schema.required === true, () => [
335
337
  (0, utils_1.create)("strong", {
336
338
  style: {
337
339
  fontSize: "var(--ifm-code-font-size)",
@@ -425,7 +427,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
425
427
  * Creates the edges or "leaves" of a schema tree. Edges can branch into sub-nodes with createDetails().
426
428
  */
427
429
  function createEdges({ name, schema, required, discriminator, }) {
428
- var _a;
430
+ var _a, _b;
429
431
  const schemaName = (0, schema_1.getSchemaName)(schema);
430
432
  if (discriminator !== undefined && discriminator.propertyName === name) {
431
433
  return createPropertyDiscriminator(name, "string", schema, discriminator, required);
@@ -446,13 +448,21 @@ function createEdges({ name, schema, required, discriminator, }) {
446
448
  if (mergedSchemas.additionalProperties !== undefined) {
447
449
  return createDetailsNode(name, mergedSchemaName, mergedSchemas, required);
448
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
+ }
449
458
  return (0, utils_1.create)("SchemaItem", {
450
459
  collapsible: false,
451
460
  name,
452
- required,
461
+ required: false,
453
462
  schemaDescription: mergedSchemas.description,
454
463
  schemaName: schemaName,
455
464
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
465
+ defaultValue: mergedSchemas.default,
456
466
  });
457
467
  }
458
468
  if (schema.properties !== undefined) {
@@ -462,17 +472,21 @@ function createEdges({ name, schema, required, discriminator, }) {
462
472
  return createDetailsNode(name, schemaName, schema, required);
463
473
  }
464
474
  // array of objects
465
- if (((_a = schema.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
475
+ if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.properties) !== undefined) {
466
476
  return createDetailsNode(name, schemaName, schema, required);
467
477
  }
478
+ if (schema.writeOnly && schema.writeOnly === true) {
479
+ return undefined;
480
+ }
468
481
  // primitives and array of non-objects
469
482
  return (0, utils_1.create)("SchemaItem", {
470
483
  collapsible: false,
471
484
  name,
472
- required,
485
+ required: false,
473
486
  schemaDescription: schema.description,
474
487
  schemaName: schemaName,
475
488
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
489
+ defaultValue: schema.default,
476
490
  });
477
491
  }
478
492
  /**
@@ -495,7 +509,8 @@ function createNodes(schema) {
495
509
  if (schema.properties !== undefined) {
496
510
  return createProperties(schema);
497
511
  }
498
- if (schema.additionalProperties !== undefined) {
512
+ // Could be set to false to just check if evals to true
513
+ if (schema.additionalProperties) {
499
514
  return createAdditionalProperties(schema);
500
515
  }
501
516
  // TODO: figure out how to handle array of objects
@@ -528,67 +543,99 @@ function createNodes(schema) {
528
543
  // So far, haven't seen this hit in testing
529
544
  return undefined;
530
545
  }
531
- function createSchemaDetails({ title, body, ...rest }) {
546
+ function createResponseSchema({ title, body, ...rest }) {
532
547
  if (body === undefined ||
533
548
  body.content === undefined ||
534
549
  Object.keys(body).length === 0 ||
535
550
  Object.keys(body.content).length === 0) {
536
551
  return undefined;
537
552
  }
538
- // NOTE: We just pick a random content-type.
539
- // How common is it to have multiple?
540
- const randomFirstKey = Object.keys(body.content)[0];
541
- const firstBody = body.content[randomFirstKey].schema;
542
- if (firstBody === undefined) {
543
- return undefined;
544
- }
545
- // we don't show the table if there is no properties to show
546
- if (firstBody.properties !== undefined) {
547
- if (Object.keys(firstBody.properties).length === 0) {
548
- return undefined;
549
- }
550
- }
551
- // Root-level schema dropdown
552
- return (0, createDetails_1.createDetails)({
553
- "data-collapsed": false,
554
- open: true,
555
- ...rest,
556
- children: [
557
- (0, createDetailsSummary_1.createDetailsSummary)({
558
- style: { textAlign: "left" },
559
- children: [
560
- (0, utils_1.create)("strong", { children: `${title}` }),
561
- (0, utils_1.guard)(firstBody.type === "array", (format) => (0, utils_1.create)("span", {
562
- style: { opacity: "0.6" },
563
- children: ` array`,
564
- })),
565
- (0, utils_1.guard)(body.required, () => [
566
- (0, utils_1.create)("strong", {
567
- style: {
568
- fontSize: "var(--ifm-code-font-size)",
569
- color: "var(--openapi-required)",
570
- },
571
- children: " required",
572
- }),
573
- ]),
574
- ],
575
- }),
576
- (0, utils_1.create)("div", {
577
- style: { textAlign: "left", marginLeft: "1rem" },
578
- children: [
579
- (0, utils_1.guard)(body.description, () => [
580
- (0, utils_1.create)("div", {
581
- style: { marginTop: "1rem", marginBottom: "1rem" },
582
- children: (0, createDescription_1.createDescription)(body.description),
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
+ ],
583
633
  }),
584
- ]),
585
- ],
586
- }),
587
- (0, utils_1.create)("ul", {
588
- style: { marginLeft: "1rem" },
589
- children: createNodes(firstBody),
634
+ ],
635
+ });
590
636
  }),
591
- ],
592
- });
637
+ });
638
+ }
639
+ return undefined;
593
640
  }
594
- exports.createSchemaDetails = createSchemaDetails;
641
+ exports.createResponseSchema = createResponseSchema;
@@ -2,5 +2,7 @@ import { ApiItem } from "../types";
2
2
  interface Props {
3
3
  responses: ApiItem["responses"];
4
4
  }
5
+ export declare function createResponseExamples(responseExamples: any): string[];
6
+ export declare function createResponseExample(responseExample: any): string;
5
7
  export declare function createStatusCodes({ responses }: Props): string | undefined;
6
8
  export {};
@@ -6,11 +6,11 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  * ========================================================================== */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createStatusCodes = void 0;
9
+ exports.createStatusCodes = exports.createResponseExample = exports.createResponseExamples = void 0;
10
10
  const createDescription_1 = require("./createDescription");
11
11
  const createDetails_1 = require("./createDetails");
12
12
  const createDetailsSummary_1 = require("./createDetailsSummary");
13
- const createSchemaDetails_1 = require("./createSchemaDetails");
13
+ const createResponseSchema_1 = require("./createResponseSchema");
14
14
  const utils_1 = require("./utils");
15
15
  const utils_2 = require("./utils");
16
16
  function createResponseHeaders(responseHeaders) {
@@ -57,17 +57,52 @@ function createResponseExamples(responseExamples) {
57
57
  return Object.entries(responseExamples).map(([exampleName, exampleValue]) => {
58
58
  const camelToSpaceName = exampleName.replace(/([A-Z])/g, " $1");
59
59
  let finalFormattedName = camelToSpaceName.charAt(0).toUpperCase() + camelToSpaceName.slice(1);
60
+ if (typeof exampleValue.value === "object") {
61
+ return (0, utils_1.create)("TabItem", {
62
+ label: `${finalFormattedName}`,
63
+ value: `${finalFormattedName}`,
64
+ children: [
65
+ (0, utils_1.create)("ResponseSamples", {
66
+ responseExample: JSON.stringify(exampleValue.value, null, 2),
67
+ }),
68
+ ],
69
+ });
70
+ }
60
71
  return (0, utils_1.create)("TabItem", {
61
72
  label: `${finalFormattedName}`,
62
73
  value: `${finalFormattedName}`,
63
74
  children: [
64
75
  (0, utils_1.create)("ResponseSamples", {
65
- responseExample: JSON.stringify(exampleValue.value, null, 2),
76
+ responseExample: exampleValue.value,
66
77
  }),
67
78
  ],
68
79
  });
69
80
  });
70
81
  }
82
+ exports.createResponseExamples = createResponseExamples;
83
+ function createResponseExample(responseExample) {
84
+ if (typeof responseExample === "object") {
85
+ return (0, utils_1.create)("TabItem", {
86
+ label: `Example`,
87
+ value: `Example`,
88
+ children: [
89
+ (0, utils_1.create)("ResponseSamples", {
90
+ responseExample: JSON.stringify(responseExample, null, 2),
91
+ }),
92
+ ],
93
+ });
94
+ }
95
+ return (0, utils_1.create)("TabItem", {
96
+ label: `Example`,
97
+ value: `Example`,
98
+ children: [
99
+ (0, utils_1.create)("ResponseSamples", {
100
+ responseExample: responseExample,
101
+ }),
102
+ ],
103
+ });
104
+ }
105
+ exports.createResponseExample = createResponseExample;
71
106
  function createStatusCodes({ responses }) {
72
107
  if (responses === undefined) {
73
108
  return undefined;
@@ -79,11 +114,10 @@ function createStatusCodes({ responses }) {
79
114
  return (0, utils_1.create)("div", {
80
115
  children: [
81
116
  (0, utils_1.create)("ApiTabs", {
117
+ // TODO: determine if we should persist status code selection
118
+ // groupId: "api-tabs",
82
119
  children: codes.map((code) => {
83
120
  const responseHeaders = responses[code].headers;
84
- const responseContent = responses[code].content;
85
- const responseContentKey = responseContent && Object.keys(responseContent)[0];
86
- const responseExamples = responseContentKey && responseContent[responseContentKey].examples;
87
121
  return (0, utils_1.create)("TabItem", {
88
122
  label: code,
89
123
  value: code,
@@ -91,62 +125,30 @@ function createStatusCodes({ responses }) {
91
125
  (0, utils_1.create)("div", {
92
126
  children: (0, createDescription_1.createDescription)(responses[code].description),
93
127
  }),
94
- (0, utils_2.guard)(responseExamples, () => (0, utils_1.create)("SchemaTabs", {
95
- children: [
96
- (0, utils_1.create)("TabTtem", {
97
- label: "Schema",
98
- value: "Schema",
99
- children: [
100
- responseHeaders &&
101
- (0, createDetails_1.createDetails)({
102
- "data-collaposed": false,
103
- open: true,
104
- style: { textAlign: "left" },
105
- children: [
106
- (0, createDetailsSummary_1.createDetailsSummary)({
107
- children: [
108
- (0, utils_1.create)("strong", {
109
- children: "Response Headers",
110
- }),
111
- ],
112
- }),
113
- createResponseHeaders(responseHeaders),
114
- ],
115
- }),
116
- (0, utils_1.create)("div", {
117
- children: (0, createSchemaDetails_1.createSchemaDetails)({
118
- title: "Schema",
119
- body: {
120
- content: responses[code].content,
121
- },
128
+ responseHeaders &&
129
+ (0, createDetails_1.createDetails)({
130
+ "data-collaposed": false,
131
+ open: true,
132
+ style: { textAlign: "left", marginBottom: "1rem" },
133
+ children: [
134
+ (0, createDetailsSummary_1.createDetailsSummary)({
135
+ children: [
136
+ (0, utils_1.create)("strong", {
137
+ children: "Response Headers",
122
138
  }),
123
- }),
124
- ],
125
- }),
126
- createResponseExamples(responseExamples),
127
- ],
128
- })),
129
- (0, utils_2.guard)(responseHeaders, () => (0, createDetails_1.createDetails)({
130
- "data-collaposed": false,
131
- open: true,
132
- style: { textAlign: "left" },
133
- children: [
134
- (0, createDetailsSummary_1.createDetailsSummary)({
135
- children: [
136
- (0, utils_1.create)("strong", { children: "Response Headers" }),
137
- ],
138
- }),
139
- createResponseHeaders(responseHeaders),
140
- ],
141
- })),
142
- (0, utils_2.guard)(!responseExamples, () => (0, utils_1.create)("div", {
143
- children: (0, createSchemaDetails_1.createSchemaDetails)({
139
+ ],
140
+ }),
141
+ createResponseHeaders(responseHeaders),
142
+ ],
143
+ }),
144
+ (0, utils_1.create)("div", {
145
+ children: (0, createResponseSchema_1.createResponseSchema)({
144
146
  title: "Schema",
145
147
  body: {
146
148
  content: responses[code].content,
147
149
  },
148
150
  }),
149
- })),
151
+ }),
150
152
  ],
151
153
  });
152
154
  }),
@@ -23,6 +23,7 @@ const utils_1 = require("./utils");
23
23
  function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }) {
24
24
  return (0, utils_1.render)([
25
25
  `import ApiTabs from "@theme/ApiTabs";\n`,
26
+ `import MimeTabs from "@theme/MimeTabs";\n`,
26
27
  `import ParamsItem from "@theme/ParamsItem";\n`,
27
28
  `import ResponseSamples from "@theme/ResponseSamples";\n`,
28
29
  `import SchemaItem from "@theme/SchemaItem"\n`,
@@ -36,7 +37,10 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
36
37
  (0, createParamsDetails_1.createParamsDetails)({ parameters, type: "query" }),
37
38
  (0, createParamsDetails_1.createParamsDetails)({ parameters, type: "header" }),
38
39
  (0, createParamsDetails_1.createParamsDetails)({ parameters, type: "cookie" }),
39
- (0, createRequestBodyDetails_1.createRequestBodyDetails)({ title: "Request Body", body: requestBody }),
40
+ (0, createRequestBodyDetails_1.createRequestBodyDetails)({
41
+ title: "Request Body",
42
+ body: requestBody,
43
+ }),
40
44
  (0, createStatusCodes_1.createStatusCodes)({ responses }),
41
45
  ]);
42
46
  }
@@ -11,11 +11,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sampleFromSchema = void 0;
13
13
  const chalk_1 = __importDefault(require("chalk"));
14
+ const createRequestSchema_1 = require("../markdown/createRequestSchema");
14
15
  const primitives = {
15
16
  string: {
16
17
  default: () => "string",
17
18
  email: () => "user@example.com",
18
19
  date: () => new Date().toISOString().substring(0, 10),
20
+ "date-time": () => new Date().toISOString().substring(0, 10),
19
21
  uuid: () => "3fa85f64-5717-4562-b3fc-2c963f66afa6",
20
22
  hostname: () => "example.com",
21
23
  ipv4: () => "198.51.100.42",
@@ -41,21 +43,15 @@ const sampleFromSchema = (schema = {}) => {
41
43
  return example;
42
44
  }
43
45
  if (allOf) {
44
- // TODO: We are just assuming it will always be an object for now
45
- let obj = {
46
- type: "object",
47
- properties: {},
48
- required: [], // NOTE: We shouldn't need to worry about required
49
- };
50
- for (let item of allOf) {
51
- if (item.properties) {
52
- obj.properties = {
53
- ...obj.properties,
54
- ...item.properties,
55
- };
46
+ const { mergedSchemas } = (0, createRequestSchema_1.mergeAllOf)(allOf);
47
+ if (mergedSchemas.properties) {
48
+ for (const [key, value] of Object.entries(mergedSchemas.properties)) {
49
+ if (value.readOnly && value.readOnly === true) {
50
+ delete mergedSchemas.properties[key];
51
+ }
56
52
  }
57
53
  }
58
- return (0, exports.sampleFromSchema)(obj);
54
+ return (0, exports.sampleFromSchema)(mergedSchemas);
59
55
  }
60
56
  if (!type) {
61
57
  if (properties) {
@@ -71,6 +67,20 @@ const sampleFromSchema = (schema = {}) => {
71
67
  if (type === "object") {
72
68
  let obj = {};
73
69
  for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
70
+ if (prop.properties) {
71
+ for (const [key, value] of Object.entries(prop.properties)) {
72
+ if (value.readOnly && value.readOnly === true) {
73
+ delete prop.properties[key];
74
+ }
75
+ }
76
+ }
77
+ if (prop.items && prop.items.properties) {
78
+ for (const [key, value] of Object.entries(prop.items.properties)) {
79
+ if (value.readOnly && value.readOnly === true) {
80
+ delete prop.items.properties[key];
81
+ }
82
+ }
83
+ }
74
84
  if (prop.deprecated) {
75
85
  continue;
76
86
  }
@@ -93,6 +103,9 @@ const sampleFromSchema = (schema = {}) => {
93
103
  }
94
104
  return normalizeArray(schema.enum)[0];
95
105
  }
106
+ if (schema.readOnly && schema.readOnly === true) {
107
+ return undefined;
108
+ }
96
109
  return primitive(schema);
97
110
  }
98
111
  catch (err) {
@@ -106,7 +119,7 @@ function primitive(schema = {}) {
106
119
  if (type === undefined) {
107
120
  return;
108
121
  }
109
- let fn = primitives[type].default;
122
+ let fn = schema.default ? () => schema.default : primitives[type].default;
110
123
  if (format !== undefined) {
111
124
  fn = primitives[type][format] || fn;
112
125
  }
@@ -6,7 +6,7 @@ interface OpenApiFiles {
6
6
  data: OpenApiObject;
7
7
  }
8
8
  export declare function readOpenapiFiles(openapiPath: string, options: APIOptions): Promise<OpenApiFiles[]>;
9
- export declare function processOpenapiFiles(files: OpenApiFiles[], sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[]]>;
9
+ export declare function processOpenapiFiles(files: OpenApiFiles[], sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[][]]>;
10
10
  export declare function processOpenapiFile(openapiData: OpenApiObject, sidebarOptions: SidebarOptions): Promise<[ApiMetadata[], TagObject[]]>;
11
11
  export declare function getTagDisplayName(tagName: string, tags: TagObject[]): string;
12
12
  export {};
@@ -59,7 +59,7 @@ async function createPostmanCollection(openapiData) {
59
59
  return await jsonToCollection(data);
60
60
  }
61
61
  function createItems(openapiData, sidebarOptions) {
62
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
63
63
  // TODO: Find a better way to handle this
64
64
  let items = [];
65
65
  const infoId = (0, kebabCase_1.default)(openapiData.info.title);
@@ -100,8 +100,8 @@ function createItems(openapiData, sidebarOptions) {
100
100
  securitySchemes: (_b = openapiData.components) === null || _b === void 0 ? void 0 : _b.securitySchemes,
101
101
  info: {
102
102
  ...openapiData.info,
103
- tags: (_c = openapiData.tags) === null || _c === void 0 ? void 0 : _c.map((tagName) => { var _a; return getTagDisplayName(tagName.name, (_a = openapiData.tags) !== null && _a !== void 0 ? _a : []); }),
104
- title: (_d = openapiData.info.title) !== null && _d !== void 0 ? _d : "Introduction",
103
+ tags: openapiData.tags,
104
+ title: (_c = openapiData.info.title) !== null && _c !== void 0 ? _c : "Introduction",
105
105
  logo: openapiData.info["x-logo"],
106
106
  darkLogo: openapiData.info["x-dark-logo"],
107
107
  },
@@ -111,18 +111,18 @@ function createItems(openapiData, sidebarOptions) {
111
111
  for (let [path, pathObject] of Object.entries(openapiData.paths)) {
112
112
  const { $ref, description, parameters, servers, summary, ...rest } = pathObject;
113
113
  for (let [method, operationObject] of Object.entries({ ...rest })) {
114
- const title = (_f = (_e = operationObject.summary) !== null && _e !== void 0 ? _e : operationObject.operationId) !== null && _f !== void 0 ? _f : "Missing summary";
114
+ const title = (_e = (_d = operationObject.summary) !== null && _d !== void 0 ? _d : operationObject.operationId) !== null && _e !== void 0 ? _e : "Missing summary";
115
115
  if (operationObject.description === undefined) {
116
116
  operationObject.description =
117
- (_h = (_g = operationObject.summary) !== null && _g !== void 0 ? _g : operationObject.operationId) !== null && _h !== void 0 ? _h : "";
117
+ (_g = (_f = operationObject.summary) !== null && _f !== void 0 ? _f : operationObject.operationId) !== null && _g !== void 0 ? _g : "";
118
118
  }
119
119
  const baseId = operationObject.operationId
120
120
  ? (0, kebabCase_1.default)(operationObject.operationId)
121
121
  : (0, kebabCase_1.default)(operationObject.summary);
122
- const servers = (_k = (_j = operationObject.servers) !== null && _j !== void 0 ? _j : pathObject.servers) !== null && _k !== void 0 ? _k : openapiData.servers;
123
- const security = (_l = operationObject.security) !== null && _l !== void 0 ? _l : openapiData.security;
122
+ const servers = (_j = (_h = operationObject.servers) !== null && _h !== void 0 ? _h : pathObject.servers) !== null && _j !== void 0 ? _j : openapiData.servers;
123
+ const security = (_k = operationObject.security) !== null && _k !== void 0 ? _k : openapiData.security;
124
124
  // Add security schemes so we know how to handle security.
125
- const securitySchemes = (_m = openapiData.components) === null || _m === void 0 ? void 0 : _m.securitySchemes;
125
+ const securitySchemes = (_l = openapiData.components) === null || _l === void 0 ? void 0 : _l.securitySchemes;
126
126
  // Make sure schemes are lowercase. See: https://github.com/cloud-annotations/docusaurus-plugin-openapi/issues/79
127
127
  if (securitySchemes) {
128
128
  for (let securityScheme of Object.values(securitySchemes)) {
@@ -132,10 +132,21 @@ function createItems(openapiData, sidebarOptions) {
132
132
  }
133
133
  }
134
134
  let jsonRequestBodyExample;
135
- const body = (_p = (_o = operationObject.requestBody) === null || _o === void 0 ? void 0 : _o.content) === null || _p === void 0 ? void 0 : _p["application/json"];
135
+ const body = (_o = (_m = operationObject.requestBody) === null || _m === void 0 ? void 0 : _m.content) === null || _o === void 0 ? void 0 : _o["application/json"];
136
136
  if (body === null || body === void 0 ? void 0 : body.schema) {
137
137
  jsonRequestBodyExample = (0, createExample_1.sampleFromSchema)(body.schema);
138
138
  }
139
+ // Handle vendor JSON media types
140
+ const bodyContent = (_p = operationObject.requestBody) === null || _p === void 0 ? void 0 : _p.content;
141
+ if (bodyContent) {
142
+ const firstBodyContentKey = Object.keys(bodyContent)[0];
143
+ if (firstBodyContentKey.endsWith("+json")) {
144
+ const firstBody = bodyContent[firstBodyContentKey];
145
+ if (firstBody === null || firstBody === void 0 ? void 0 : firstBody.schema) {
146
+ jsonRequestBodyExample = (0, createExample_1.sampleFromSchema)(firstBody.schema);
147
+ }
148
+ }
149
+ }
139
150
  // TODO: Don't include summary temporarilly
140
151
  const { summary, ...defaults } = operationObject;
141
152
  const apiPage = {
@@ -148,7 +159,7 @@ function createItems(openapiData, sidebarOptions) {
148
159
  frontMatter: {},
149
160
  api: {
150
161
  ...defaults,
151
- tags: (_q = operationObject.tags) === null || _q === void 0 ? void 0 : _q.map((tagName) => { var _a; return getTagDisplayName(tagName, (_a = openapiData.tags) !== null && _a !== void 0 ? _a : []); }),
162
+ tags: operationObject.tags,
152
163
  method,
153
164
  path,
154
165
  servers,
@@ -30,7 +30,7 @@ export interface InfoObject {
30
30
  contact?: ContactObject;
31
31
  license?: LicenseObject;
32
32
  version: string;
33
- tags?: String[];
33
+ tags?: TagObject[];
34
34
  "x-logo"?: LogoObject;
35
35
  "x-dark-logo"?: LogoObject;
36
36
  logo?: LogoObject;