docusaurus-plugin-openapi-docs 3.0.0-beta.1 → 3.0.0-beta.10

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 (74) hide show
  1. package/README.md +2 -0
  2. package/lib/index.js +75 -19
  3. package/lib/markdown/createAuthentication.js +4 -3
  4. package/lib/markdown/createCallbacks.d.ts +6 -0
  5. package/lib/markdown/createCallbacks.js +78 -0
  6. package/lib/markdown/createDeprecationNotice.js +6 -3
  7. package/lib/markdown/createDescription.js +1 -9
  8. package/lib/markdown/createHeading.js +4 -5
  9. package/lib/markdown/createRequestBodyDetails.d.ts +1 -1
  10. package/lib/markdown/createRequestHeader.d.ts +1 -1
  11. package/lib/markdown/createRequestHeader.js +10 -1
  12. package/lib/markdown/createRequestSchema.js +2 -2
  13. package/lib/markdown/createResponseSchema.js +1 -1
  14. package/lib/markdown/createSchema.d.ts +2 -2
  15. package/lib/markdown/createSchema.js +52 -19
  16. package/lib/markdown/createSchema.test.js +2 -2
  17. package/lib/markdown/createStatusCodes.d.ts +3 -1
  18. package/lib/markdown/createStatusCodes.js +8 -6
  19. package/lib/markdown/createVersionBadge.js +1 -1
  20. package/lib/markdown/index.d.ts +3 -2
  21. package/lib/markdown/index.js +31 -6
  22. package/lib/markdown/schema.js +3 -0
  23. package/lib/markdown/utils.d.ts +9 -3
  24. package/lib/markdown/utils.js +29 -4
  25. package/lib/openapi/openapi.d.ts +3 -3
  26. package/lib/openapi/openapi.js +61 -8
  27. package/lib/openapi/openapi.test.js +2 -0
  28. package/lib/openapi/types.d.ts +18 -13
  29. package/lib/openapi/utils/services/OpenAPIParser.d.ts +1 -1
  30. package/lib/openapi/utils/services/OpenAPIParser.js +2 -1
  31. package/lib/openapi/utils/services/RedocNormalizedOptions.js +49 -49
  32. package/lib/openapi/utils/types/index.d.ts +1 -1
  33. package/lib/openapi/utils/types/open-api.d.ts +4 -4
  34. package/lib/openapi/utils/types.d.ts +5 -5
  35. package/lib/openapi/utils/utils/openapi.js +1 -1
  36. package/lib/options.js +2 -1
  37. package/lib/sidebars/index.d.ts +2 -2
  38. package/lib/sidebars/index.js +49 -9
  39. package/lib/types.d.ts +16 -3
  40. package/package.json +11 -9
  41. package/src/index.ts +134 -21
  42. package/src/markdown/__snapshots__/createSchema.test.ts.snap +4 -28
  43. package/src/markdown/createAuthentication.ts +11 -6
  44. package/src/markdown/createCallbacks.ts +101 -0
  45. package/src/markdown/createContactInfo.ts +1 -1
  46. package/src/markdown/createDeprecationNotice.ts +2 -2
  47. package/src/markdown/createDescription.ts +2 -10
  48. package/src/markdown/createHeading.ts +10 -7
  49. package/src/markdown/createLicense.ts +1 -1
  50. package/src/markdown/createLogo.ts +1 -1
  51. package/src/markdown/createParamsDetails.ts +1 -1
  52. package/src/markdown/createRequestBodyDetails.ts +2 -2
  53. package/src/markdown/createRequestHeader.ts +15 -1
  54. package/src/markdown/createRequestSchema.ts +3 -3
  55. package/src/markdown/createResponseSchema.ts +2 -2
  56. package/src/markdown/createSchema.test.ts +6 -4
  57. package/src/markdown/createSchema.ts +67 -29
  58. package/src/markdown/createStatusCodes.ts +11 -7
  59. package/src/markdown/createVersionBadge.ts +8 -4
  60. package/src/markdown/index.ts +45 -14
  61. package/src/markdown/schema.ts +4 -0
  62. package/src/markdown/utils.ts +37 -4
  63. package/src/openapi/__fixtures__/examples/openapi.yaml +29 -0
  64. package/src/openapi/createRequestExample.ts +1 -1
  65. package/src/openapi/createResponseExample.ts +1 -1
  66. package/src/openapi/openapi.test.ts +3 -0
  67. package/src/openapi/openapi.ts +78 -11
  68. package/src/openapi/types.ts +6 -0
  69. package/src/openapi/utils/loadAndResolveSpec.ts +1 -1
  70. package/src/openapi/utils/services/OpenAPIParser.ts +3 -3
  71. package/src/openapi/utils/utils/openapi.ts +8 -8
  72. package/src/options.ts +2 -1
  73. package/src/sidebars/index.ts +70 -15
  74. package/src/types.ts +21 -1
@@ -0,0 +1,101 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ import { createDescription } from "./createDescription";
9
+ import { createMethodEndpoint } from "./createMethodEndpoint";
10
+ import { createRequestBodyDetails } from "./createRequestBodyDetails";
11
+ import { createStatusCodes } from "./createStatusCodes";
12
+ import { create } from "./utils";
13
+ import { MediaTypeObject } from "../openapi/types";
14
+ import { ApiItem } from "../types";
15
+
16
+ interface Props {
17
+ callbacks: ApiItem["callbacks"];
18
+ }
19
+
20
+ interface RequestBodyProps {
21
+ title: string;
22
+ body: {
23
+ content?: {
24
+ [key: string]: MediaTypeObject;
25
+ };
26
+ description?: string;
27
+ required?: boolean;
28
+ };
29
+ }
30
+
31
+ export function createCallbacks({ callbacks }: Props) {
32
+ if (callbacks === undefined) {
33
+ return undefined;
34
+ }
35
+
36
+ const callbacksNames = Object.keys(callbacks);
37
+ if (callbacksNames.length === 0) {
38
+ return undefined;
39
+ }
40
+
41
+ return create("div", {
42
+ children: [
43
+ create("div", {
44
+ className: "openapi__divider",
45
+ }),
46
+ create(
47
+ "Heading",
48
+ {
49
+ children: "Callbacks",
50
+ id: "callbacks",
51
+ as: "h2",
52
+ className: "openapi-tabs__heading",
53
+ },
54
+ { inline: true }
55
+ ),
56
+ create("OperationTabs", {
57
+ className: "openapi-tabs__operation",
58
+ children: callbacksNames.flatMap((name) => {
59
+ const path = Object.keys(callbacks[name])[0];
60
+ const methods = new Map([
61
+ ["delete", callbacks[name][path].delete],
62
+ ["get", callbacks[name][path].get],
63
+ ["head", callbacks[name][path].head],
64
+ ["options", callbacks[name][path].options],
65
+ ["patch", callbacks[name][path].patch],
66
+ ["post", callbacks[name][path].post],
67
+ ["put", callbacks[name][path].put],
68
+ ["trace", callbacks[name][path].trace],
69
+ ]);
70
+
71
+ return Array.from(methods).flatMap(([method, operationObject]) => {
72
+ if (!operationObject) return [];
73
+
74
+ const { description, requestBody, responses } = operationObject;
75
+
76
+ return [
77
+ create("TabItem", {
78
+ label: `${method.toUpperCase()} ${name}`,
79
+ value: `${method}-${name}`,
80
+ children: [
81
+ createMethodEndpoint(method, path),
82
+ // TODO: add `deprecation notice` when markdown support is added
83
+ createDescription(description),
84
+ createRequestBodyDetails({
85
+ title: "Body",
86
+ body: requestBody,
87
+ } as RequestBodyProps),
88
+ createStatusCodes({
89
+ id: "callbacks-responses",
90
+ label: "Callbacks Responses",
91
+ responses,
92
+ }),
93
+ ],
94
+ }),
95
+ ];
96
+ });
97
+ }),
98
+ }),
99
+ ],
100
+ });
101
+ }
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { ContactObject } from "../openapi/types";
9
8
  import { create, guard } from "./utils";
9
+ import { ContactObject } from "../openapi/types";
10
10
 
11
11
  export function createContactInfo(contact: ContactObject) {
12
12
  if (!contact || !Object.keys(contact).length) return "";
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { guard, Props, render } from "./utils";
8
+ import { clean, guard, Props, render } from "./utils";
9
9
 
10
10
  function createAdmonition({ children }: Props) {
11
11
  return `:::caution deprecated\n\n${render(children)}\n\n:::`;
@@ -23,7 +23,7 @@ export function createDeprecationNotice({
23
23
  return guard(deprecated, () =>
24
24
  createAdmonition({
25
25
  children:
26
- description ??
26
+ clean(description) ??
27
27
  "This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
28
28
  })
29
29
  );
@@ -5,16 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { greaterThan, codeFence, lessThan } from "./utils";
8
+ import { clean } from "./utils";
9
9
 
10
10
  export function createDescription(description: string | undefined) {
11
- if (!description) {
12
- return "";
13
- }
14
- return `\n\n${description
15
- .replace(lessThan, "<")
16
- .replace(greaterThan, ">")
17
- .replace(codeFence, function (match) {
18
- return match.replace(/\\>/g, ">");
19
- })}\n\n`;
11
+ return `\n\n${clean(description)}\n\n`;
20
12
  }
@@ -5,16 +5,19 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { create, greaterThan, lessThan } from "./utils";
8
+ import { clean, create } from "./utils";
9
9
 
10
10
  export function createHeading(heading: string) {
11
11
  return [
12
- create("h1", {
13
- className: "openapi__heading",
14
- children: `${heading
15
- .replace(lessThan, "<")
16
- .replace(greaterThan, ">")}`,
17
- }),
12
+ create(
13
+ "Heading",
14
+ {
15
+ children: clean(heading),
16
+ as: "h1",
17
+ className: "openapi__heading",
18
+ },
19
+ { inline: true }
20
+ ),
18
21
  `\n\n`,
19
22
  ];
20
23
  }
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { LicenseObject } from "../openapi/types";
9
8
  import { create, guard } from "./utils";
9
+ import { LicenseObject } from "../openapi/types";
10
10
 
11
11
  export function createLicense(license: LicenseObject) {
12
12
  if (!license || !Object.keys(license).length) return "";
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { LogoObject } from "../openapi/types";
9
8
  import { create, guard } from "./utils";
9
+ import { LogoObject } from "../openapi/types";
10
10
 
11
11
  export function createLogo(
12
12
  logo: LogoObject | undefined,
@@ -5,10 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { ApiItem } from "../types";
9
8
  import { createDetails } from "./createDetails";
10
9
  import { createDetailsSummary } from "./createDetailsSummary";
11
10
  import { create } from "./utils";
11
+ import { ApiItem } from "../types";
12
12
 
13
13
  interface Props {
14
14
  parameters: ApiItem["parameters"];
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { MediaTypeObject } from "../openapi/types";
9
8
  import { createRequestSchema } from "./createRequestSchema";
9
+ import { MediaTypeObject } from "../openapi/types";
10
10
 
11
11
  interface Props {
12
12
  title: string;
@@ -19,6 +19,6 @@ interface Props {
19
19
  };
20
20
  }
21
21
 
22
- export function createRequestBodyDetails({ title, body }: Props): any {
22
+ export function createRequestBodyDetails({ title, body }: Props) {
23
23
  return createRequestSchema({ title, body });
24
24
  }
@@ -5,6 +5,20 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
+ import { create } from "./utils";
9
+
8
10
  export function createRequestHeader(header: string) {
9
- return `## ${header}\n\n`;
11
+ return [
12
+ create(
13
+ "Heading",
14
+ {
15
+ children: header,
16
+ id: header.replace(" ", "-").toLowerCase(),
17
+ as: "h2",
18
+ className: "openapi-tabs__heading",
19
+ },
20
+ { inline: true }
21
+ ),
22
+ `\n\n`,
23
+ ];
10
24
  }
@@ -5,12 +5,12 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { MediaTypeObject } from "../openapi/types";
9
8
  import { createDescription } from "./createDescription";
10
9
  import { createDetails } from "./createDetails";
11
10
  import { createDetailsSummary } from "./createDetailsSummary";
12
11
  import { createNodes } from "./createSchema";
13
12
  import { create, guard } from "./utils";
13
+ import { MediaTypeObject } from "../openapi/types";
14
14
 
15
15
  interface Props {
16
16
  style?: any;
@@ -90,7 +90,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
90
90
  }),
91
91
  create("ul", {
92
92
  style: { marginLeft: "1rem" },
93
- children: createNodes(firstBody),
93
+ children: createNodes(firstBody, "request"),
94
94
  }),
95
95
  ],
96
96
  }),
@@ -161,7 +161,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
161
161
  }),
162
162
  create("ul", {
163
163
  style: { marginLeft: "1rem" },
164
- children: createNodes(firstBody),
164
+ children: createNodes(firstBody, "request"),
165
165
  }),
166
166
  ],
167
167
  }),
@@ -5,7 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import { MediaTypeObject } from "../openapi/types";
9
8
  import { createDescription } from "./createDescription";
10
9
  import { createDetails } from "./createDetails";
11
10
  import { createDetailsSummary } from "./createDetailsSummary";
@@ -16,6 +15,7 @@ import {
16
15
  createResponseExamples,
17
16
  } from "./createStatusCodes";
18
17
  import { create, guard } from "./utils";
18
+ import { MediaTypeObject } from "../openapi/types";
19
19
 
20
20
  interface Props {
21
21
  style?: any;
@@ -118,7 +118,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
118
118
  }),
119
119
  create("ul", {
120
120
  style: { marginLeft: "1rem" },
121
- children: createNodes(firstBody!),
121
+ children: createNodes(firstBody!, "response"),
122
122
  }),
123
123
  ],
124
124
  }),
@@ -7,11 +7,11 @@
7
7
 
8
8
  import * as prettier from "prettier";
9
9
 
10
- import { SchemaObject } from "../openapi/types";
11
10
  import { createNodes } from "./createSchema";
11
+ import { SchemaObject } from "../openapi/types";
12
12
 
13
13
  describe("createNodes", () => {
14
- it("should create readable MODs for oneOf primitive properties", () => {
14
+ it("should create readable MODs for oneOf primitive properties", async () => {
15
15
  const schema: SchemaObject = {
16
16
  type: "object",
17
17
  properties: {
@@ -48,8 +48,10 @@ describe("createNodes", () => {
48
48
  },
49
49
  };
50
50
  expect(
51
- createNodes(schema).map((md: any) =>
52
- prettier.format(md, { parser: "babel" })
51
+ await Promise.all(
52
+ createNodes(schema, "request").map(
53
+ async (md: any) => await prettier.format(md, { parser: "babel" })
54
+ )
53
55
  )
54
56
  ).toMatchSnapshot();
55
57
  });
@@ -7,7 +7,6 @@
7
7
 
8
8
  import clsx from "clsx";
9
9
 
10
- import { SchemaObject } from "../openapi/types";
11
10
  import {
12
11
  createClosingArrayBracket,
13
12
  createOpeningArrayBracket,
@@ -17,9 +16,12 @@ import { createDetails } from "./createDetails";
17
16
  import { createDetailsSummary } from "./createDetailsSummary";
18
17
  import { getQualifierMessage, getSchemaName } from "./schema";
19
18
  import { create, guard } from "./utils";
19
+ import { SchemaObject } from "../openapi/types";
20
20
 
21
21
  const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
22
22
 
23
+ let SCHEMA_TYPE: "request" | "response";
24
+
23
25
  /**
24
26
  * Returns a merged representation of allOf array of schemas.
25
27
  */
@@ -29,6 +31,9 @@ export function mergeAllOf(allOf: SchemaObject[]) {
29
31
  readOnly: function () {
30
32
  return true;
31
33
  },
34
+ writeOnly: function () {
35
+ return true;
36
+ },
32
37
  example: function () {
33
38
  return true;
34
39
  },
@@ -39,7 +44,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
39
44
  ignoreAdditionalProperties: true,
40
45
  });
41
46
 
42
- const required = allOf.reduce((acc, cur) => {
47
+ const mergedRequired = allOf.reduce((acc, cur) => {
43
48
  if (Array.isArray(cur.required)) {
44
49
  const next = [...acc, ...cur.required];
45
50
  return next;
@@ -47,7 +52,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
47
52
  return acc;
48
53
  }, [] as any);
49
54
 
50
- return { mergedSchemas, required };
55
+ return { mergedSchemas, mergedRequired };
51
56
  }
52
57
 
53
58
  /**
@@ -74,7 +79,7 @@ function createAnyOneOf(schema: SchemaObject): any {
74
79
  }
75
80
 
76
81
  if (anyOneSchema.allOf !== undefined) {
77
- anyOneChildren.push(createNodes(anyOneSchema));
82
+ anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
78
83
  delete anyOneSchema.allOf;
79
84
  }
80
85
 
@@ -89,7 +94,7 @@ function createAnyOneOf(schema: SchemaObject): any {
89
94
  anyOneSchema.type === "integer" ||
90
95
  anyOneSchema.type === "boolean"
91
96
  ) {
92
- anyOneChildren.push(createNodes(anyOneSchema));
97
+ anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
93
98
  }
94
99
  if (anyOneChildren.length) {
95
100
  if (schema.type === "array") {
@@ -255,9 +260,8 @@ function createItems(schema: SchemaObject) {
255
260
  // TODO: figure out if and how we should pass merged required array
256
261
  const {
257
262
  mergedSchemas,
258
- }: { mergedSchemas: SchemaObject; required: string[] } = mergeAllOf(
259
- schema.items?.allOf
260
- );
263
+ }: { mergedSchemas: SchemaObject; mergedRequired: string[] | boolean } =
264
+ mergeAllOf(schema.items?.allOf);
261
265
 
262
266
  // Handles combo anyOf/oneOf + properties
263
267
  if (
@@ -304,7 +308,7 @@ function createItems(schema: SchemaObject) {
304
308
  ) {
305
309
  return [
306
310
  createOpeningArrayBracket(),
307
- createNodes(schema.items),
311
+ createNodes(schema.items, SCHEMA_TYPE),
308
312
  createClosingArrayBracket(),
309
313
  ].flat();
310
314
  }
@@ -411,7 +415,7 @@ function createDetailsNode(
411
415
  children: createDescription(description),
412
416
  })
413
417
  ),
414
- createNodes(schema),
418
+ createNodes(schema, SCHEMA_TYPE),
415
419
  ],
416
420
  }),
417
421
  ],
@@ -565,7 +569,7 @@ function createPropertyDiscriminator(
565
569
  // className: "openapi-tabs__discriminator-item",
566
570
  label: label,
567
571
  value: `${index}-item-discriminator`,
568
- children: [createNodes(discriminator?.mapping[key])],
572
+ children: [createNodes(discriminator?.mapping[key], SCHEMA_TYPE)],
569
573
  });
570
574
  }),
571
575
  }),
@@ -591,7 +595,6 @@ function createEdges({
591
595
  discriminator,
592
596
  }: EdgeProps): any {
593
597
  const schemaName = getSchemaName(schema);
594
-
595
598
  if (discriminator !== undefined && discriminator.propertyName === name) {
596
599
  return createPropertyDiscriminator(
597
600
  name,
@@ -613,13 +616,10 @@ function createEdges({
613
616
  }
614
617
 
615
618
  if (schema.allOf !== undefined) {
616
- const {
617
- mergedSchemas,
618
- required,
619
- }: { mergedSchemas: SchemaObject; required: string[] | boolean } =
620
- mergeAllOf(schema.allOf);
619
+ const { mergedSchemas }: { mergedSchemas: SchemaObject } = mergeAllOf(
620
+ schema.allOf
621
+ );
621
622
  const mergedSchemaName = getSchemaName(mergedSchemas);
622
-
623
623
  if (
624
624
  mergedSchemas.oneOf !== undefined ||
625
625
  mergedSchemas.anyOf !== undefined
@@ -664,16 +664,24 @@ function createEdges({
664
664
  );
665
665
  }
666
666
 
667
- if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
668
- return undefined;
667
+ if (SCHEMA_TYPE === "request") {
668
+ if (mergedSchemas.readOnly && mergedSchemas.readOnly === true) {
669
+ return undefined;
670
+ }
671
+ }
672
+
673
+ if (SCHEMA_TYPE === "response") {
674
+ if (mergedSchemas.writeOnly && mergedSchemas.writeOnly === true) {
675
+ return undefined;
676
+ }
669
677
  }
670
678
 
671
679
  return create("SchemaItem", {
672
680
  collapsible: false,
673
681
  name,
674
682
  required: Array.isArray(required) ? required.includes(name) : required,
675
- schemaName: schemaName,
676
- qualifierMessage: getQualifierMessage(schema),
683
+ schemaName: mergedSchemaName,
684
+ qualifierMessage: getQualifierMessage(mergedSchemas),
677
685
  schema: mergedSchemas,
678
686
  });
679
687
  }
@@ -719,8 +727,16 @@ function createEdges({
719
727
  );
720
728
  }
721
729
 
722
- if (schema.readOnly && schema.readOnly === true) {
723
- return undefined;
730
+ if (SCHEMA_TYPE === "request") {
731
+ if (schema.readOnly && schema.readOnly === true) {
732
+ return undefined;
733
+ }
734
+ }
735
+
736
+ if (SCHEMA_TYPE === "response") {
737
+ if (schema.writeOnly && schema.writeOnly === true) {
738
+ return undefined;
739
+ }
724
740
  }
725
741
 
726
742
  // primitives and array of non-objects
@@ -737,7 +753,11 @@ function createEdges({
737
753
  /**
738
754
  * Creates a hierarchical level of a schema tree. Nodes produce edges that can branch into sub-nodes with edges, recursively.
739
755
  */
740
- export function createNodes(schema: SchemaObject): any {
756
+ export function createNodes(
757
+ schema: SchemaObject,
758
+ schemaType: "request" | "response"
759
+ ): any {
760
+ SCHEMA_TYPE = schemaType;
741
761
  const nodes = [];
742
762
  // if (schema.discriminator !== undefined) {
743
763
  // return createDiscriminator(schema);
@@ -792,9 +812,18 @@ export function createNodes(schema: SchemaObject): any {
792
812
  style: {
793
813
  marginTop: ".5rem",
794
814
  marginBottom: ".5rem",
795
- marginLeft: "1rem",
796
815
  },
797
- children: createDescription(schema.type),
816
+ children: [
817
+ createDescription(schema.type),
818
+ guard(getQualifierMessage(schema), (message) =>
819
+ create("div", {
820
+ style: {
821
+ paddingTop: "1rem",
822
+ },
823
+ children: createDescription(message),
824
+ })
825
+ ),
826
+ ],
798
827
  });
799
828
  }
800
829
 
@@ -804,9 +833,18 @@ export function createNodes(schema: SchemaObject): any {
804
833
  style: {
805
834
  marginTop: ".5rem",
806
835
  marginBottom: ".5rem",
807
- marginLeft: "1rem",
808
836
  },
809
- children: [createDescription(schema)],
837
+ children: [
838
+ createDescription(schema),
839
+ guard(getQualifierMessage(schema), (message) =>
840
+ create("div", {
841
+ style: {
842
+ paddingTop: "1rem",
843
+ },
844
+ children: createDescription(message),
845
+ })
846
+ ),
847
+ ],
810
848
  });
811
849
  }
812
850
 
@@ -7,14 +7,14 @@
7
7
 
8
8
  import format from "xml-formatter";
9
9
 
10
- import { sampleResponseFromSchema } from "../openapi/createResponseExample";
11
- import { ApiItem } from "../types";
12
10
  import { createDescription } from "./createDescription";
13
11
  import { createDetails } from "./createDetails";
14
12
  import { createDetailsSummary } from "./createDetailsSummary";
15
13
  import { createResponseSchema } from "./createResponseSchema";
16
14
  import { create } from "./utils";
17
15
  import { guard } from "./utils";
16
+ import { sampleResponseFromSchema } from "../openapi/createResponseExample";
17
+ import { ApiItem } from "../types";
18
18
 
19
19
  export default function json2xml(o: any, tab: any) {
20
20
  var toXml = function (v: any, name: string, ind: any) {
@@ -54,6 +54,8 @@ export default function json2xml(o: any, tab: any) {
54
54
  }
55
55
 
56
56
  interface Props {
57
+ id?: string;
58
+ label?: string;
57
59
  responses: ApiItem["responses"];
58
60
  }
59
61
 
@@ -125,7 +127,7 @@ export function createResponseExamples(
125
127
  value: `${exampleName}`,
126
128
  children: [
127
129
  guard(exampleValue.summary, (summary) => [
128
- create("p", {
130
+ create("Markdown", {
129
131
  children: ` ${summary}`,
130
132
  }),
131
133
  ]),
@@ -141,7 +143,7 @@ export function createResponseExamples(
141
143
  value: `${exampleName}`,
142
144
  children: [
143
145
  guard(exampleValue.summary, (summary) => [
144
- create("p", {
146
+ create("Markdown", {
145
147
  children: ` ${summary}`,
146
148
  }),
147
149
  ]),
@@ -169,7 +171,7 @@ export function createResponseExample(responseExample: any, mimeType: string) {
169
171
  value: `Example`,
170
172
  children: [
171
173
  guard(responseExample.summary, (summary) => [
172
- create("p", {
174
+ create("Markdown", {
173
175
  children: ` ${summary}`,
174
176
  }),
175
177
  ]),
@@ -185,7 +187,7 @@ export function createResponseExample(responseExample: any, mimeType: string) {
185
187
  value: `Example`,
186
188
  children: [
187
189
  guard(responseExample.summary, (summary) => [
188
- create("p", {
190
+ create("Markdown", {
189
191
  children: ` ${summary}`,
190
192
  }),
191
193
  ]),
@@ -254,7 +256,7 @@ export function createExampleFromSchema(schema: any, mimeType: string) {
254
256
  return undefined;
255
257
  }
256
258
 
257
- export function createStatusCodes({ responses }: Props) {
259
+ export function createStatusCodes({ label, id, responses }: Props) {
258
260
  if (responses === undefined) {
259
261
  return undefined;
260
262
  }
@@ -269,6 +271,8 @@ export function createStatusCodes({ responses }: Props) {
269
271
  create("div", {
270
272
  children: [
271
273
  create("ApiTabs", {
274
+ label,
275
+ id,
272
276
  children: codes.map((code) => {
273
277
  const responseHeaders: any = responses[code].headers;
274
278
  return create("TabItem", {
@@ -9,10 +9,14 @@ import { create, guard } from "./utils";
9
9
 
10
10
  export function createVersionBadge(version: string | undefined) {
11
11
  return guard(version, (version) => [
12
- create("span", {
13
- className: "theme-doc-version-badge badge badge--secondary",
14
- children: `Version: ${escape(version)}`,
15
- }),
12
+ create(
13
+ "span",
14
+ {
15
+ className: "theme-doc-version-badge badge badge--secondary",
16
+ children: `Version: ${escape(version)}`,
17
+ },
18
+ { inline: true }
19
+ ),
16
20
  `\n\n`,
17
21
  ]);
18
22
  }