docusaurus-plugin-openapi-docs 4.1.0 → 4.3.0

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.
Files changed (41) hide show
  1. package/README.md +21 -1
  2. package/lib/index.d.ts +1 -1
  3. package/lib/index.js +66 -0
  4. package/lib/markdown/createAuthentication.js +3 -3
  5. package/lib/markdown/createContactInfo.js +1 -1
  6. package/lib/markdown/createParamsDetails.d.ts +1 -2
  7. package/lib/markdown/createParamsDetails.js +7 -42
  8. package/lib/markdown/createRequestBodyDetails.d.ts +1 -1
  9. package/lib/markdown/createRequestSchema.d.ts +1 -1
  10. package/lib/markdown/createRequestSchema.js +8 -132
  11. package/lib/markdown/createResponseSchema.d.ts +1 -1
  12. package/lib/markdown/createResponseSchema.js +8 -94
  13. package/lib/markdown/createSchema.d.ts +1 -4
  14. package/lib/markdown/createSchema.js +32 -56
  15. package/lib/markdown/createStatusCodes.d.ts +1 -4
  16. package/lib/markdown/createStatusCodes.js +10 -259
  17. package/lib/markdown/createTermsOfService.js +1 -1
  18. package/lib/markdown/index.js +11 -22
  19. package/lib/openapi/createRequestExample.js +2 -2
  20. package/lib/openapi/createResponseExample.js +2 -2
  21. package/lib/openapi/openapi.js +3 -1
  22. package/lib/openapi/types.d.ts +1 -0
  23. package/lib/options.js +1 -0
  24. package/package.json +9 -6
  25. package/src/index.ts +88 -5
  26. package/src/markdown/__snapshots__/createSchema.test.ts.snap +55 -0
  27. package/src/markdown/createAuthentication.ts +3 -3
  28. package/src/markdown/createContactInfo.ts +1 -1
  29. package/src/markdown/createParamsDetails.ts +7 -49
  30. package/src/markdown/createRequestSchema.ts +9 -143
  31. package/src/markdown/createResponseSchema.ts +9 -112
  32. package/src/markdown/createSchema.ts +29 -61
  33. package/src/markdown/createStatusCodes.ts +9 -268
  34. package/src/markdown/createTermsOfService.ts +1 -1
  35. package/src/markdown/index.ts +11 -22
  36. package/src/openapi/createRequestExample.ts +2 -5
  37. package/src/openapi/createResponseExample.ts +2 -5
  38. package/src/openapi/openapi.ts +3 -1
  39. package/src/openapi/types.ts +1 -0
  40. package/src/openapi/utils/loadAndResolveSpec.ts +1 -1
  41. package/src/options.ts +1 -0
@@ -5,6 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
+ // eslint-disable-next-line import/no-extraneous-dependencies
9
+ import { merge } from "allof-merge";
8
10
  import clsx from "clsx";
9
11
  import isEmpty from "lodash/isEmpty";
10
12
 
@@ -19,41 +21,18 @@ import { getQualifierMessage, getSchemaName } from "./schema";
19
21
  import { create, guard } from "./utils";
20
22
  import { SchemaObject } from "../openapi/types";
21
23
 
22
- const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
23
-
24
24
  let SCHEMA_TYPE: "request" | "response";
25
25
 
26
26
  /**
27
27
  * Returns a merged representation of allOf array of schemas.
28
28
  */
29
- export function mergeAllOf(allOf: SchemaObject[]) {
30
- const mergedSchemas = jsonSchemaMergeAllOf(allOf, {
31
- resolvers: {
32
- readOnly: function () {
33
- return true;
34
- },
35
- writeOnly: function () {
36
- return true;
37
- },
38
- example: function () {
39
- return true;
40
- },
41
- "x-examples": function () {
42
- return true;
43
- },
44
- },
45
- ignoreAdditionalProperties: true,
46
- });
47
-
48
- const mergedRequired = allOf.reduce((acc, cur) => {
49
- if (Array.isArray(cur.required)) {
50
- const next = [...acc, ...cur.required];
51
- return next;
52
- }
53
- return acc;
54
- }, [] as any);
29
+ export function mergeAllOf(allOf: SchemaObject) {
30
+ const onMergeError = (msg: string) => {
31
+ console.warn(msg);
32
+ };
55
33
 
56
- return { mergedSchemas, mergedRequired };
34
+ const mergedSchemas = merge(allOf, { onMergeError }) as SchemaObject;
35
+ return mergedSchemas;
57
36
  }
58
37
 
59
38
  /**
@@ -271,10 +250,7 @@ function createItems(schema: SchemaObject) {
271
250
 
272
251
  if (schema.items?.allOf !== undefined) {
273
252
  // TODO: figure out if and how we should pass merged required array
274
- const {
275
- mergedSchemas,
276
- }: { mergedSchemas: SchemaObject; mergedRequired: string[] | boolean } =
277
- mergeAllOf(schema.items?.allOf);
253
+ const mergedSchemas = mergeAllOf(schema.items) as SchemaObject;
278
254
 
279
255
  // Handles combo anyOf/oneOf + properties
280
256
  if (
@@ -683,61 +659,53 @@ function createEdges({
683
659
  );
684
660
  }
685
661
 
686
- if (schema.allOf !== undefined) {
687
- const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
688
- schema.allOf
689
- );
690
- delete schema.allOf;
691
- const combinedSchemas = { ...schema, ...mergedSchemas };
662
+ if (schema.items?.allOf !== undefined) {
663
+ const mergedSchemas = mergeAllOf(schema.items);
692
664
 
693
665
  if (SCHEMA_TYPE === "request") {
694
- if (combinedSchemas.readOnly && combinedSchemas.readOnly === true) {
666
+ if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
695
667
  return undefined;
696
668
  }
697
669
  }
698
670
 
699
671
  if (SCHEMA_TYPE === "response") {
700
- if (combinedSchemas.writeOnly && combinedSchemas.writeOnly === true) {
672
+ if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
701
673
  return undefined;
702
674
  }
703
675
  }
704
676
 
705
- const mergedSchemaName = getSchemaName(combinedSchemas);
706
-
707
- if (name === "eventName") {
708
- console.log(mergedSchemaName, combinedSchemas);
709
- }
677
+ const mergedSchemaName = getSchemaName(mergedSchemas);
710
678
 
711
679
  if (
712
- combinedSchemas.oneOf !== undefined ||
713
- combinedSchemas.anyOf !== undefined
680
+ mergedSchemas.oneOf !== undefined ||
681
+ mergedSchemas.anyOf !== undefined
714
682
  ) {
715
683
  return createDetailsNode(
716
684
  name,
717
685
  mergedSchemaName,
718
- combinedSchemas,
686
+ mergedSchemas,
719
687
  required,
720
- combinedSchemas.nullable
688
+ mergedSchemas.nullable
721
689
  );
722
690
  }
723
691
 
724
- if (combinedSchemas.properties !== undefined) {
692
+ if (mergedSchemas.properties !== undefined) {
725
693
  return createDetailsNode(
726
694
  name,
727
695
  mergedSchemaName,
728
- combinedSchemas,
696
+ mergedSchemas,
729
697
  required,
730
- combinedSchemas.nullable
698
+ mergedSchemas.nullable
731
699
  );
732
700
  }
733
701
 
734
- if (combinedSchemas.additionalProperties !== undefined) {
702
+ if (mergedSchemas.additionalProperties !== undefined) {
735
703
  return createDetailsNode(
736
704
  name,
737
705
  mergedSchemaName,
738
- combinedSchemas,
706
+ mergedSchemas,
739
707
  required,
740
- combinedSchemas.nullable
708
+ mergedSchemas.nullable
741
709
  );
742
710
  }
743
711
 
@@ -746,9 +714,9 @@ function createEdges({
746
714
  return createDetailsNode(
747
715
  name,
748
716
  mergedSchemaName,
749
- combinedSchemas,
717
+ mergedSchemas,
750
718
  required,
751
- combinedSchemas.nullable
719
+ mergedSchemas.nullable
752
720
  );
753
721
  }
754
722
 
@@ -757,8 +725,8 @@ function createEdges({
757
725
  name,
758
726
  required: Array.isArray(required) ? required.includes(name) : required,
759
727
  schemaName: mergedSchemaName,
760
- qualifierMessage: getQualifierMessage(combinedSchemas),
761
- schema: combinedSchemas,
728
+ qualifierMessage: getQualifierMessage(mergedSchemas),
729
+ schema: mergedSchemas,
762
730
  });
763
731
  }
764
732
 
@@ -815,7 +783,7 @@ export function createNodes(
815
783
  }
816
784
 
817
785
  if (schema.allOf !== undefined) {
818
- const { mergedSchemas } = mergeAllOf(schema.allOf);
786
+ const mergedSchemas = mergeAllOf(schema) as SchemaObject;
819
787
 
820
788
  if (
821
789
  mergedSchemas.oneOf !== undefined ||
@@ -5,15 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import format from "xml-formatter";
9
-
10
- import { createDescription } from "./createDescription";
11
- import { createDetails } from "./createDetails";
12
- import { createDetailsSummary } from "./createDetailsSummary";
13
- import { createResponseSchema } from "./createResponseSchema";
14
8
  import { create } from "./utils";
15
- import { guard } from "./utils";
16
- import { sampleResponseFromSchema } from "../openapi/createResponseExample";
17
9
  import { ApiItem } from "../types";
18
10
 
19
11
  export default function json2xml(o: any, tab: any) {
@@ -59,264 +51,13 @@ interface Props {
59
51
  responses: ApiItem["responses"];
60
52
  }
61
53
 
62
- function createResponseHeaders(responseHeaders: any) {
63
- return guard(responseHeaders, () =>
64
- create("ul", {
65
- style: { marginLeft: "1rem" },
66
- children: [
67
- Object.entries(responseHeaders).map(
68
- ([headerName, headerObj]: [any, any]) => {
69
- const { description, example }: any = headerObj;
70
- const type = headerObj.schema?.type ?? "any";
71
-
72
- return create("li", {
73
- className: "schemaItem",
74
- children: [
75
- createDetailsSummary({
76
- children: [
77
- create("strong", { children: headerName }),
78
- guard(type, () => [
79
- create("span", {
80
- style: { opacity: "0.6" },
81
- children: ` ${type}`,
82
- }),
83
- ]),
84
- ],
85
- }),
86
- create("div", {
87
- children: [
88
- guard(description, (description) =>
89
- create("div", {
90
- style: {
91
- marginTop: ".5rem",
92
- marginBottom: ".5rem",
93
- },
94
- children: [
95
- guard(example, () => `Example: ${example}`),
96
- createDescription(description),
97
- ],
98
- })
99
- ),
100
- ],
101
- }),
102
- ],
103
- });
104
- }
105
- ),
106
- ],
107
- })
108
- );
109
- }
110
-
111
- export function createResponseExamples(
112
- responseExamples: any,
113
- mimeType: string
114
- ) {
115
- let language = "shell";
116
- if (mimeType.endsWith("json")) {
117
- language = "json";
118
- }
119
- if (mimeType.endsWith("xml")) {
120
- language = "xml";
121
- }
122
- return Object.entries(responseExamples).map(
123
- ([exampleName, exampleValue]: any) => {
124
- if (typeof exampleValue.value === "object") {
125
- return create("TabItem", {
126
- label: `${exampleName}`,
127
- value: `${exampleName}`,
128
- children: [
129
- guard(exampleValue.summary, (summary) => [
130
- create("div", {
131
- children: `${summary}`,
132
- className: "openapi-example__summary",
133
- }),
134
- ]),
135
- create("ResponseSamples", {
136
- responseExample: JSON.stringify(exampleValue.value, null, 2),
137
- language: language,
138
- }),
139
- ],
140
- });
141
- }
142
- return create("TabItem", {
143
- label: `${exampleName}`,
144
- value: `${exampleName}`,
145
- children: [
146
- guard(exampleValue.summary, (summary) => [
147
- create("div", {
148
- children: `${summary}`,
149
- className: "openapi-example__summary",
150
- }),
151
- ]),
152
- create("ResponseSamples", {
153
- responseExample: exampleValue.value,
154
- language: language,
155
- }),
156
- ],
157
- });
158
- }
159
- );
160
- }
161
-
162
- export function createResponseExample(responseExample: any, mimeType: string) {
163
- let language = "shell";
164
- if (mimeType.endsWith("json")) {
165
- language = "json";
166
- }
167
- if (mimeType.endsWith("xml")) {
168
- language = "xml";
169
- }
170
- if (typeof responseExample === "object") {
171
- return create("TabItem", {
172
- label: `Example`,
173
- value: `Example`,
174
- children: [
175
- guard(responseExample.summary, (summary) => [
176
- create("div", {
177
- children: `${summary}`,
178
- className: "openapi-example__summary",
179
- }),
180
- ]),
181
- create("ResponseSamples", {
182
- responseExample: JSON.stringify(responseExample, null, 2),
183
- language: language,
184
- }),
185
- ],
186
- });
187
- }
188
- return create("TabItem", {
189
- label: `Example`,
190
- value: `Example`,
191
- children: [
192
- guard(responseExample.summary, (summary) => [
193
- create("div", {
194
- children: `${summary}`,
195
- className: "openapi-example__summary",
196
- }),
197
- ]),
198
- create("ResponseSamples", {
199
- responseExample: responseExample,
200
- language: language,
201
- }),
202
- ],
203
- });
204
- }
205
-
206
- export function createExampleFromSchema(schema: any, mimeType: string) {
207
- const responseExample = sampleResponseFromSchema(schema);
208
- if (mimeType.endsWith("xml")) {
209
- let responseExampleObject;
210
- try {
211
- responseExampleObject = JSON.parse(JSON.stringify(responseExample));
212
- } catch {
213
- return undefined;
214
- }
215
-
216
- if (typeof responseExampleObject === "object") {
217
- let xmlExample;
218
- try {
219
- xmlExample = format(json2xml(responseExampleObject, ""), {
220
- indentation: " ",
221
- lineSeparator: "\n",
222
- collapseContent: true,
223
- });
224
- } catch {
225
- const xmlExampleWithRoot = { root: responseExampleObject };
226
- try {
227
- xmlExample = format(json2xml(xmlExampleWithRoot, ""), {
228
- indentation: " ",
229
- lineSeparator: "\n",
230
- collapseContent: true,
231
- });
232
- } catch {
233
- xmlExample = json2xml(responseExampleObject, "");
234
- }
235
- }
236
- return create("TabItem", {
237
- label: `Example (from schema)`,
238
- value: `Example (from schema)`,
239
- children: [
240
- create("ResponseSamples", {
241
- responseExample: xmlExample,
242
- language: "xml",
243
- }),
244
- ],
245
- });
246
- }
247
- }
248
- if (typeof responseExample === "object") {
249
- return create("TabItem", {
250
- label: `Example (from schema)`,
251
- value: `Example (from schema)`,
252
- children: [
253
- create("ResponseSamples", {
254
- responseExample: JSON.stringify(responseExample, null, 2),
255
- language: "json",
256
- }),
257
- ],
258
- });
259
- }
260
- return undefined;
261
- }
262
-
263
- export function createStatusCodes({ label, id, responses }: Props) {
264
- if (responses === undefined) {
265
- return undefined;
266
- }
267
-
268
- const codes = Object.keys(responses);
269
- if (codes.length === 0) {
270
- return undefined;
271
- }
272
-
273
- return create("div", {
274
- children: [
275
- create("div", {
276
- children: [
277
- create("ApiTabs", {
278
- label,
279
- id,
280
- children: codes.map((code) => {
281
- const responseHeaders: any = responses[code].headers;
282
- return create("TabItem", {
283
- label: code,
284
- value: code,
285
- children: [
286
- create("div", {
287
- children: createDescription(responses[code].description),
288
- }),
289
- responseHeaders &&
290
- createDetails({
291
- className: "openapi-markdown__details",
292
- "data-collapsed": true,
293
- open: false,
294
- style: { textAlign: "left", marginBottom: "1rem" },
295
- children: [
296
- createDetailsSummary({
297
- children: [
298
- create("strong", {
299
- children: "Response Headers",
300
- }),
301
- ],
302
- }),
303
- createResponseHeaders(responseHeaders),
304
- ],
305
- }),
306
- create("div", {
307
- children: createResponseSchema({
308
- title: "Schema",
309
- body: {
310
- content: responses[code].content,
311
- },
312
- }),
313
- }),
314
- ],
315
- });
316
- }),
317
- }),
318
- ],
319
- }),
320
- ],
321
- });
54
+ export function createStatusCodes({ id, label, responses }: Props) {
55
+ return [
56
+ create("StatusCodes", {
57
+ id: id,
58
+ label: label,
59
+ responses: responses,
60
+ }),
61
+ "\n\n",
62
+ ];
322
63
  }
@@ -23,7 +23,7 @@ export function createTermsOfService(termsOfService: string | undefined) {
23
23
  }),
24
24
  create("a", {
25
25
  href: `${termsOfService}`,
26
- children: termsOfService,
26
+ children: `{'${termsOfService}'}`,
27
27
  }),
28
28
  ],
29
29
  });
@@ -19,7 +19,6 @@ import { createMethodEndpoint } from "./createMethodEndpoint";
19
19
  import { createParamsDetails } from "./createParamsDetails";
20
20
  import { createRequestBodyDetails } from "./createRequestBodyDetails";
21
21
  import { createRequestHeader } from "./createRequestHeader";
22
- import { createNodes } from "./createSchema";
23
22
  import { createStatusCodes } from "./createStatusCodes";
24
23
  import { createTermsOfService } from "./createTermsOfService";
25
24
  import { createVendorExtensions } from "./createVendorExtensions";
@@ -67,18 +66,13 @@ export function createApiPageMD({
67
66
  frontMatter,
68
67
  }: ApiPageMetadata) {
69
68
  return render([
70
- `import ApiTabs from "@theme/ApiTabs";\n`,
71
- `import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
72
69
  `import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";\n`,
73
- `import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";\n`,
74
- `import MimeTabs from "@theme/MimeTabs";\n`,
75
- `import ParamsItem from "@theme/ParamsItem";\n`,
76
- `import ResponseSamples from "@theme/ResponseSamples";\n`,
77
- `import SchemaItem from "@theme/SchemaItem";\n`,
78
- `import SchemaTabs from "@theme/SchemaTabs";\n`,
79
- `import Heading from "@theme/Heading";\n`,
70
+ `import ParamsDetails from "@theme/ParamsDetails";\n`,
71
+ `import RequestSchema from "@theme/RequestSchema";\n`,
72
+ `import StatusCodes from "@theme/StatusCodes";\n`,
80
73
  `import OperationTabs from "@theme/OperationTabs";\n`,
81
- `import TabItem from "@theme/TabItem";\n\n`,
74
+ `import TabItem from "@theme/TabItem";\n`,
75
+ `import Heading from "@theme/Heading";\n\n`,
82
76
  createHeading(title),
83
77
  createMethodEndpoint(method, path),
84
78
  infoPath && createAuthorization(infoPath),
@@ -88,10 +82,7 @@ export function createApiPageMD({
88
82
  createDeprecationNotice({ deprecated, description: deprecatedDescription }),
89
83
  createDescription(description),
90
84
  requestBody || parameters ? createRequestHeader("Request") : undefined,
91
- createParamsDetails({ parameters, type: "path" }),
92
- createParamsDetails({ parameters, type: "query" }),
93
- createParamsDetails({ parameters, type: "header" }),
94
- createParamsDetails({ parameters, type: "cookie" }),
85
+ createParamsDetails({ parameters }),
95
86
  createRequestBodyDetails({
96
87
  title: "Body",
97
88
  body: requestBody,
@@ -141,15 +132,13 @@ export function createTagPageMD({ tag: { description } }: TagPageMetadata) {
141
132
  export function createSchemaPageMD({ schema }: SchemaPageMetadata) {
142
133
  const { title = "", description } = schema;
143
134
  return render([
144
- `import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
145
- `import SchemaItem from "@theme/SchemaItem";\n`,
146
- `import SchemaTabs from "@theme/SchemaTabs";\n`,
147
- `import Heading from "@theme/Heading";\n`,
148
- `import TabItem from "@theme/TabItem";\n\n`,
135
+ `import Schema from "@theme/Schema";\n`,
136
+ `import Heading from "@theme/Heading";\n\n`,
149
137
  createHeading(title.replace(lessThan, "<").replace(greaterThan, ">")),
150
138
  createDescription(description),
151
- create("ul", {
152
- children: createNodes(schema, "response"),
139
+ create("Schema", {
140
+ schema: schema,
141
+ schemaType: "response",
153
142
  }),
154
143
  ]);
155
144
  }
@@ -66,9 +66,7 @@ function sampleRequestFromProp(name: string, prop: any, obj: any): any {
66
66
  } else if (prop.anyOf) {
67
67
  obj[name] = sampleRequestFromSchema(prop.anyOf[0]);
68
68
  } else if (prop.allOf) {
69
- const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
70
- prop.allOf
71
- );
69
+ const mergedSchemas = mergeAllOf(prop) as SchemaObject;
72
70
  sampleRequestFromProp(name, mergedSchemas, obj);
73
71
  } else {
74
72
  obj[name] = sampleRequestFromSchema(prop);
@@ -107,8 +105,7 @@ export const sampleRequestFromSchema = (schema: SchemaObject = {}): any => {
107
105
  }
108
106
 
109
107
  if (allOf) {
110
- const { mergedSchemas }: { mergedSchemas: SchemaObject } =
111
- mergeAllOf(allOf);
108
+ const mergedSchemas = mergeAllOf(schemaCopy) as SchemaObject;
112
109
  if (mergedSchemas.properties) {
113
110
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
114
111
  if ((value.readOnly && value.readOnly === true) || value.deprecated) {
@@ -66,9 +66,7 @@ function sampleResponseFromProp(name: string, prop: any, obj: any): any {
66
66
  } else if (prop.anyOf) {
67
67
  obj[name] = sampleResponseFromSchema(prop.anyOf[0]);
68
68
  } else if (prop.allOf) {
69
- const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
70
- prop.allOf
71
- );
69
+ const mergedSchemas = mergeAllOf(prop) as SchemaObject;
72
70
  sampleResponseFromProp(name, mergedSchemas, obj);
73
71
  } else {
74
72
  obj[name] = sampleResponseFromSchema(prop);
@@ -87,8 +85,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
87
85
  }
88
86
 
89
87
  if (allOf) {
90
- const { mergedSchemas }: { mergedSchemas: SchemaObject } =
91
- mergeAllOf(allOf);
88
+ const mergedSchemas = mergeAllOf(schemaCopy) as SchemaObject;
92
89
  if (mergedSchemas.properties) {
93
90
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
94
91
  if (
@@ -20,7 +20,6 @@ import sdk from "postman-collection";
20
20
 
21
21
  import { sampleRequestFromSchema } from "./createRequestExample";
22
22
  import { OpenApiObject, TagGroupObject, TagObject } from "./types";
23
- import { loadAndResolveSpec } from "./utils/loadAndResolveSpec";
24
23
  import { isURL } from "../index";
25
24
  import {
26
25
  ApiMetadata,
@@ -31,6 +30,8 @@ import {
31
30
  SidebarOptions,
32
31
  TagPageMetadata,
33
32
  } from "../types";
33
+ import { sampleResponseFromSchema } from "./createResponseExample";
34
+ import { loadAndResolveSpec } from "./utils/loadAndResolveSpec";
34
35
 
35
36
  /**
36
37
  * Convenience function for converting raw JSON to a Postman Collection object.
@@ -451,6 +452,7 @@ function createItems(
451
452
  .replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'")
452
453
  .replace(/\s+$/, "")
453
454
  : "",
455
+ sample: JSON.stringify(sampleResponseFromSchema(schemaObject)),
454
456
  },
455
457
  schema: schemaObject,
456
458
  };
@@ -238,6 +238,7 @@ export interface MediaTypeObject {
238
238
  example?: any;
239
239
  examples?: Map<ExampleObject>;
240
240
  encoding?: Map<EncodingObject>;
241
+ type?: any;
241
242
  }
242
243
 
243
244
  export interface MediaTypeObjectWithRef {
@@ -13,8 +13,8 @@ import chalk from "chalk";
13
13
  // @ts-ignore
14
14
  import { convertObj } from "swagger2openapi";
15
15
 
16
- import { OpenAPIParser } from "./services/OpenAPIParser";
17
16
  import { OpenApiObject } from "../types";
17
+ import { OpenAPIParser } from "./services/OpenAPIParser";
18
18
 
19
19
  function serializer(replacer: any, cycleReplacer: any) {
20
20
  var stack: any = [],
package/src/options.ts CHANGED
@@ -24,6 +24,7 @@ const markdownGenerators = Joi.object({
24
24
  createApiPageMD: Joi.function(),
25
25
  createInfoPageMD: Joi.function(),
26
26
  createTagPageMD: Joi.function(),
27
+ createSchemaPageMD: Joi.function(),
27
28
  });
28
29
 
29
30
  export const OptionsSchema = Joi.object({