docusaurus-theme-openapi-docs 4.3.7 → 4.5.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 (51) hide show
  1. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +3 -3
  2. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +5 -1
  3. package/lib/theme/ApiExplorer/Authorization/slice.js +2 -2
  4. package/lib/theme/ApiExplorer/Body/slice.js +2 -2
  5. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +3 -3
  6. package/lib/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +4 -2
  7. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +4 -4
  8. package/lib/theme/ApiExplorer/Request/index.js +27 -6
  9. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +1 -1
  10. package/lib/theme/ApiExplorer/Request/makeRequest.js +3 -2
  11. package/lib/theme/ApiExplorer/Response/slice.js +2 -2
  12. package/lib/theme/ApiExplorer/Server/slice.js +2 -2
  13. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
  14. package/lib/theme/ApiExplorer/buildPostmanRequest.js +119 -46
  15. package/lib/theme/ApiExplorer/index.js +58 -2
  16. package/lib/theme/CodeSamples/_CodeSamples.scss +3 -0
  17. package/lib/theme/CodeSamples/index.d.ts +8 -0
  18. package/lib/theme/{ResponseSamples → CodeSamples}/index.js +4 -4
  19. package/lib/theme/ParamsItem/index.d.ts +1 -4
  20. package/lib/theme/ParamsItem/index.js +4 -1
  21. package/lib/theme/ResponseExamples/index.js +9 -9
  22. package/lib/theme/Schema/index.js +73 -133
  23. package/lib/theme/SchemaItem/index.js +34 -0
  24. package/lib/theme/styles.scss +1 -1
  25. package/lib/types.d.ts +5 -116
  26. package/package.json +5 -3
  27. package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +3 -3
  28. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.tsx +5 -1
  29. package/src/theme/ApiExplorer/Body/index.tsx +1 -2
  30. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +3 -3
  31. package/src/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +4 -2
  32. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +4 -4
  33. package/src/theme/ApiExplorer/Request/index.tsx +28 -5
  34. package/src/theme/ApiExplorer/Request/makeRequest.ts +4 -3
  35. package/src/theme/ApiExplorer/buildPostmanRequest.ts +48 -18
  36. package/src/theme/ApiExplorer/index.tsx +4 -2
  37. package/src/theme/CodeSamples/_CodeSamples.scss +3 -0
  38. package/src/theme/{ResponseSamples → CodeSamples}/index.tsx +5 -10
  39. package/src/theme/ParamsItem/index.tsx +7 -6
  40. package/src/theme/ResponseExamples/index.tsx +6 -9
  41. package/src/theme/Schema/index.tsx +69 -96
  42. package/src/theme/SchemaItem/index.tsx +27 -0
  43. package/src/theme/styles.scss +1 -1
  44. package/src/types.ts +5 -115
  45. package/tsconfig.tsbuildinfo +1 -1
  46. package/lib/theme/ResponseSamples/_ResponseSamples.scss +0 -3
  47. package/lib/theme/ResponseSamples/index.d.ts +0 -8
  48. package/src/theme/ApiExplorer/postman-collection.d.ts +0 -10
  49. package/src/theme/ApiExplorer/react-modal.d.ts +0 -8
  50. package/src/theme/ResponseSamples/_ResponseSamples.scss +0 -3
  51. package/src/theme-translations.d.ts +0 -9
@@ -44,9 +44,12 @@ function ParamsItem({ param, ...rest }) {
44
44
  } = param;
45
45
  let schema = param.schema;
46
46
  let defaultValue;
47
- if (!schema || !schema?.type) {
47
+ if (!schema) {
48
48
  schema = { type: "any" };
49
49
  }
50
+ if (!schema.type) {
51
+ schema.type = "any";
52
+ }
50
53
  if (schema) {
51
54
  if (schema.items) {
52
55
  defaultValue = schema.items.default;
@@ -17,8 +17,8 @@ exports.ExampleFromSchema =
17
17
  void 0;
18
18
  exports.json2xml = json2xml;
19
19
  const react_1 = __importDefault(require("react"));
20
+ const CodeSamples_1 = __importDefault(require("@theme/CodeSamples"));
20
21
  const Markdown_1 = __importDefault(require("@theme/Markdown"));
21
- const ResponseSamples_1 = __importDefault(require("@theme/ResponseSamples"));
22
22
  const TabItem_1 = __importDefault(require("@theme/TabItem"));
23
23
  const createResponseExample_1 = require("docusaurus-plugin-openapi-docs/lib/openapi/createResponseExample");
24
24
  const xml_formatter_1 = __importDefault(require("xml-formatter"));
@@ -80,8 +80,8 @@ const ResponseExamples = ({ responseExamples, mimeType }) => {
80
80
  { className: "openapi-example__summary" },
81
81
  exampleValue.summary
82
82
  ),
83
- react_1.default.createElement(ResponseSamples_1.default, {
84
- responseExample: responseExample,
83
+ react_1.default.createElement(CodeSamples_1.default, {
84
+ example: responseExample,
85
85
  language: language,
86
86
  })
87
87
  )
@@ -114,8 +114,8 @@ const ResponseExample = ({ responseExample, mimeType }) => {
114
114
  { className: "openapi-example__summary" },
115
115
  responseExample.summary
116
116
  ),
117
- react_1.default.createElement(ResponseSamples_1.default, {
118
- responseExample: exampleContent,
117
+ react_1.default.createElement(CodeSamples_1.default, {
118
+ example: exampleContent,
119
119
  language: language,
120
120
  })
121
121
  )
@@ -164,8 +164,8 @@ const ExampleFromSchema = ({ schema, mimeType }) => {
164
164
  react_1.default.createElement(
165
165
  TabItem_1.default,
166
166
  { label: "Example (auto)", value: "Example (auto)" },
167
- react_1.default.createElement(ResponseSamples_1.default, {
168
- responseExample: xmlExample,
167
+ react_1.default.createElement(CodeSamples_1.default, {
168
+ example: xmlExample,
169
169
  language: "xml",
170
170
  })
171
171
  )
@@ -181,8 +181,8 @@ const ExampleFromSchema = ({ schema, mimeType }) => {
181
181
  react_1.default.createElement(
182
182
  TabItem_1.default,
183
183
  { label: "Example (auto)", value: "Example (auto)" },
184
- react_1.default.createElement(ResponseSamples_1.default, {
185
- responseExample: JSON.stringify(responseExample, null, 2),
184
+ react_1.default.createElement(CodeSamples_1.default, {
185
+ example: JSON.stringify(responseExample, null, 2),
186
186
  language: "json",
187
187
  })
188
188
  )
@@ -108,15 +108,13 @@ const AnyOneOf = ({ schema, schemaType }) => {
108
108
  SchemaTabs_1.default,
109
109
  null,
110
110
  schema[type]?.map((anyOneSchema, index) => {
111
- const label = anyOneSchema.title || `MOD${index + 1}`;
111
+ const label = anyOneSchema.title || anyOneSchema.type;
112
112
  return (
113
113
  // @ts-ignore
114
114
  react_1.default.createElement(
115
115
  TabItem_1.default,
116
116
  { key: index, label: label, value: `${index}-item-properties` },
117
- ["string", "number", "integer", "boolean"].includes(
118
- anyOneSchema.type
119
- ) &&
117
+ (isPrimitive(anyOneSchema) || anyOneSchema.const) &&
120
118
  react_1.default.createElement(SchemaItem_1.default, {
121
119
  collapsible: false,
122
120
  name: undefined,
@@ -344,7 +342,8 @@ const DiscriminatorNode = ({ discriminator, schema, schemaType }) => {
344
342
  mergedSubSchema = mergeAllOf(subSchema);
345
343
  }
346
344
  const subProperties = subSchema.properties || mergedSubSchema.properties;
347
- if (subProperties[discriminator.propertyName]) {
345
+ // Add a safeguard check to avoid referencing subProperties if it's undefined
346
+ if (subProperties && subProperties[discriminator.propertyName]) {
348
347
  if (schema.properties) {
349
348
  schema.properties[discriminator.propertyName] = {
350
349
  ...schema.properties[discriminator.propertyName],
@@ -482,111 +481,45 @@ const SchemaNodeDetails = ({
482
481
  );
483
482
  };
484
483
  const Items = ({ schema, schemaType }) => {
485
- // Handles case when schema.items has properties
486
- if (schema.items?.properties) {
487
- return react_1.default.createElement(
488
- react_1.default.Fragment,
489
- null,
490
- react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
491
- react_1.default.createElement(Properties, {
492
- schema: schema.items,
493
- schemaType: schemaType,
494
- }),
495
- react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
496
- );
497
- }
498
- // Handles case when schema.items has additionalProperties
499
- if (schema.items?.additionalProperties) {
500
- return react_1.default.createElement(
501
- react_1.default.Fragment,
502
- null,
503
- react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
504
- react_1.default.createElement(AdditionalProperties, {
505
- schema: schema.items,
506
- schemaType: schemaType,
507
- }),
508
- react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
509
- );
484
+ // Process schema.items to handle allOf merging
485
+ let itemsSchema = schema.items;
486
+ if (schema.items?.allOf) {
487
+ itemsSchema = mergeAllOf(schema.items);
510
488
  }
511
- // Handles case when schema.items has oneOf or anyOf
512
- if (schema.items?.oneOf || schema.items?.anyOf) {
489
+ // Handle complex schemas with multiple schema types
490
+ const hasOneOfAnyOf = itemsSchema?.oneOf || itemsSchema?.anyOf;
491
+ const hasProperties = itemsSchema?.properties;
492
+ const hasAdditionalProperties = itemsSchema?.additionalProperties;
493
+ if (hasOneOfAnyOf || hasProperties || hasAdditionalProperties) {
513
494
  return react_1.default.createElement(
514
495
  react_1.default.Fragment,
515
496
  null,
516
497
  react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
517
- react_1.default.createElement(AnyOneOf, {
518
- schema: schema.items,
519
- schemaType: schemaType,
520
- }),
521
- react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
522
- );
523
- }
524
- // Handles case when schema.items has allOf
525
- if (schema.items?.allOf) {
526
- const mergedSchemas = mergeAllOf(schema.items);
527
- // Handles combo anyOf/oneOf + properties
528
- if (
529
- (mergedSchemas.oneOf || mergedSchemas.anyOf) &&
530
- mergedSchemas.properties
531
- ) {
532
- return react_1.default.createElement(
533
- react_1.default.Fragment,
534
- null,
535
- react_1.default.createElement(
536
- ArrayBrackets_1.OpeningArrayBracket,
537
- null
538
- ),
498
+ hasOneOfAnyOf &&
539
499
  react_1.default.createElement(AnyOneOf, {
540
- schema: mergedSchemas,
500
+ schema: itemsSchema,
541
501
  schemaType: schemaType,
542
502
  }),
503
+ hasProperties &&
543
504
  react_1.default.createElement(Properties, {
544
- schema: mergedSchemas,
505
+ schema: itemsSchema,
545
506
  schemaType: schemaType,
546
507
  }),
547
- react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
548
- );
549
- }
550
- // Handles only anyOf/oneOf
551
- if (mergedSchemas.oneOf || mergedSchemas.anyOf) {
552
- return react_1.default.createElement(
553
- react_1.default.Fragment,
554
- null,
555
- react_1.default.createElement(
556
- ArrayBrackets_1.OpeningArrayBracket,
557
- null
558
- ),
559
- react_1.default.createElement(AnyOneOf, {
560
- schema: mergedSchemas,
508
+ hasAdditionalProperties &&
509
+ react_1.default.createElement(AdditionalProperties, {
510
+ schema: itemsSchema,
561
511
  schemaType: schemaType,
562
512
  }),
563
- react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
564
- );
565
- }
566
- // Handles properties
567
- if (mergedSchemas.properties) {
568
- return react_1.default.createElement(
569
- react_1.default.Fragment,
570
- null,
571
- react_1.default.createElement(
572
- ArrayBrackets_1.OpeningArrayBracket,
573
- null
574
- ),
575
- react_1.default.createElement(Properties, {
576
- schema: mergedSchemas,
577
- schemaType: schemaType,
578
- }),
579
- react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
580
- );
581
- }
513
+ react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
514
+ );
582
515
  }
583
516
  // Handles basic types (string, number, integer, boolean, object)
584
517
  if (
585
- schema.items?.type === "string" ||
586
- schema.items?.type === "number" ||
587
- schema.items?.type === "integer" ||
588
- schema.items?.type === "boolean" ||
589
- schema.items?.type === "object"
518
+ itemsSchema?.type === "string" ||
519
+ itemsSchema?.type === "number" ||
520
+ itemsSchema?.type === "integer" ||
521
+ itemsSchema?.type === "boolean" ||
522
+ itemsSchema?.type === "object"
590
523
  ) {
591
524
  return react_1.default.createElement(
592
525
  "div",
@@ -595,9 +528,9 @@ const Items = ({ schema, schemaType }) => {
595
528
  react_1.default.createElement(SchemaItem_1.default, {
596
529
  collapsible: false,
597
530
  name: "", // No name for array items
598
- schemaName: (0, schema_1.getSchemaName)(schema.items),
599
- qualifierMessage: (0, schema_1.getQualifierMessage)(schema.items),
600
- schema: schema.items,
531
+ schemaName: (0, schema_1.getSchemaName)(itemsSchema),
532
+ qualifierMessage: (0, schema_1.getQualifierMessage)(itemsSchema),
533
+ schema: itemsSchema,
601
534
  discriminator: false,
602
535
  children: null,
603
536
  }),
@@ -609,7 +542,7 @@ const Items = ({ schema, schemaType }) => {
609
542
  react_1.default.Fragment,
610
543
  null,
611
544
  react_1.default.createElement(ArrayBrackets_1.OpeningArrayBracket, null),
612
- Object.entries(schema.items || {}).map(([key, val]) =>
545
+ Object.entries(itemsSchema || {}).map(([key, val]) =>
613
546
  react_1.default.createElement(SchemaEdge, {
614
547
  key: key,
615
548
  name: key,
@@ -777,6 +710,37 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
777
710
  children: null,
778
711
  });
779
712
  };
713
+ function renderChildren(schema, schemaType) {
714
+ return react_1.default.createElement(
715
+ react_1.default.Fragment,
716
+ null,
717
+ schema.oneOf &&
718
+ react_1.default.createElement(AnyOneOf, {
719
+ schema: schema,
720
+ schemaType: schemaType,
721
+ }),
722
+ schema.anyOf &&
723
+ react_1.default.createElement(AnyOneOf, {
724
+ schema: schema,
725
+ schemaType: schemaType,
726
+ }),
727
+ schema.properties &&
728
+ react_1.default.createElement(Properties, {
729
+ schema: schema,
730
+ schemaType: schemaType,
731
+ }),
732
+ schema.additionalProperties &&
733
+ react_1.default.createElement(AdditionalProperties, {
734
+ schema: schema,
735
+ schemaType: schemaType,
736
+ }),
737
+ schema.items &&
738
+ react_1.default.createElement(Items, {
739
+ schema: schema,
740
+ schemaType: schemaType,
741
+ })
742
+ );
743
+ }
780
744
  const SchemaNode = ({ schema, schemaType }) => {
781
745
  if (
782
746
  (schemaType === "request" && schema.readOnly) ||
@@ -826,12 +790,6 @@ const SchemaNode = ({ schema, schemaType }) => {
826
790
  })
827
791
  );
828
792
  }
829
- if (schema.oneOf || schema.anyOf) {
830
- return react_1.default.createElement(AnyOneOf, {
831
- schema: schema,
832
- schemaType: schemaType,
833
- });
834
- }
835
793
  // Handle primitives
836
794
  if (
837
795
  schema.type &&
@@ -854,34 +812,16 @@ const SchemaNode = ({ schema, schemaType }) => {
854
812
  children: null,
855
813
  });
856
814
  }
857
- return react_1.default.createElement(
858
- "div",
859
- null,
860
- schema.oneOf &&
861
- react_1.default.createElement(AnyOneOf, {
862
- schema: schema,
863
- schemaType: schemaType,
864
- }),
865
- schema.anyOf &&
866
- react_1.default.createElement(AnyOneOf, {
867
- schema: schema,
868
- schemaType: schemaType,
869
- }),
870
- schema.properties &&
871
- react_1.default.createElement(Properties, {
872
- schema: schema,
873
- schemaType: schemaType,
874
- }),
875
- schema.additionalProperties &&
876
- react_1.default.createElement(AdditionalProperties, {
877
- schema: schema,
878
- schemaType: schemaType,
879
- }),
880
- schema.items &&
881
- react_1.default.createElement(Items, {
882
- schema: schema,
883
- schemaType: schemaType,
884
- })
885
- );
815
+ return renderChildren(schema, schemaType);
886
816
  };
887
817
  exports.default = SchemaNode;
818
+ const PRIMITIVE_TYPES = {
819
+ string: true,
820
+ number: true,
821
+ integer: true,
822
+ boolean: true,
823
+ null: true,
824
+ };
825
+ const isPrimitive = (schema) => {
826
+ return PRIMITIVE_TYPES[schema.type];
827
+ };
@@ -51,6 +51,7 @@ function SchemaItem(props) {
51
51
  let example;
52
52
  let nullable;
53
53
  let enumDescriptions = [];
54
+ let constValue;
54
55
  if (schema) {
55
56
  deprecated = schema.deprecated;
56
57
  schemaDescription = schema.description;
@@ -60,6 +61,7 @@ function SchemaItem(props) {
60
61
  nullable =
61
62
  schema.nullable ||
62
63
  (Array.isArray(schema.type) && schema.type.includes("null")); // support JSON Schema nullable
64
+ constValue = schema.const;
63
65
  }
64
66
  const renderRequired = (0, utils_1.guard)(
65
67
  Array.isArray(required) ? required.includes(name) : required,
@@ -170,6 +172,37 @@ function SchemaItem(props) {
170
172
  }
171
173
  return undefined;
172
174
  }
175
+ function renderConstValue() {
176
+ if (constValue !== undefined) {
177
+ if (typeof constValue === "string") {
178
+ return react_1.default.createElement(
179
+ "div",
180
+ null,
181
+ react_1.default.createElement("strong", null, "Constant value: "),
182
+ react_1.default.createElement(
183
+ "span",
184
+ null,
185
+ react_1.default.createElement("code", null, constValue)
186
+ )
187
+ );
188
+ }
189
+ return react_1.default.createElement(
190
+ "div",
191
+ null,
192
+ react_1.default.createElement("strong", null, "Constant value: "),
193
+ react_1.default.createElement(
194
+ "span",
195
+ null,
196
+ react_1.default.createElement(
197
+ "code",
198
+ null,
199
+ JSON.stringify(constValue)
200
+ )
201
+ )
202
+ );
203
+ }
204
+ return undefined;
205
+ }
173
206
  const schemaContent = react_1.default.createElement(
174
207
  "div",
175
208
  null,
@@ -201,6 +234,7 @@ function SchemaItem(props) {
201
234
  renderSchemaDescription,
202
235
  renderEnumDescriptions,
203
236
  renderQualifierMessage,
237
+ renderConstValue(),
204
238
  renderDefaultValue(),
205
239
  renderExample(),
206
240
  collapsibleSchemaContent ?? collapsibleSchemaContent
@@ -38,7 +38,7 @@
38
38
  @use "./SchemaTabs/SchemaTabs";
39
39
  @use "./OperationTabs/OperationTabs";
40
40
  /* Code Samples */
41
- @use "./ResponseSamples/ResponseSamples";
41
+ @use "./CodeSamples/CodeSamples";
42
42
  /* Markdown Styling */
43
43
  @use "./Markdown/Details/Details";
44
44
 
package/lib/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FrontMatterTag } from "@docusaurus/utils";
1
+ import type { DocFrontMatter as DocusaurusDocFrontMatter } from "@docusaurus/plugin-content-docs";
2
2
  import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
3
3
  export interface ThemeConfig {
4
4
  api?: {
@@ -6,9 +6,6 @@ export interface ThemeConfig {
6
6
  authPersistance?: false | "localStorage" | "sessionStorage";
7
7
  };
8
8
  }
9
- interface Map<T> {
10
- [key: string]: T;
11
- }
12
9
  export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
13
10
  export type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf" | "not" | "items" | "properties" | "additionalProperties"> & {
14
11
  type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
@@ -17,7 +14,7 @@ export type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf"
17
14
  anyOf?: SchemaObject[];
18
15
  not?: SchemaObject;
19
16
  items?: SchemaObject;
20
- properties?: Map<SchemaObject>;
17
+ properties?: Record<string, SchemaObject>;
21
18
  additionalProperties?: boolean | SchemaObject;
22
19
  nullable?: boolean;
23
20
  discriminator?: DiscriminatorObject;
@@ -30,7 +27,7 @@ export type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf"
30
27
  };
31
28
  export interface DiscriminatorObject {
32
29
  propertyName: string;
33
- mapping?: Map<string>;
30
+ mapping?: Record<string, string>;
34
31
  }
35
32
  export interface XMLObject {
36
33
  name?: string;
@@ -43,115 +40,7 @@ export interface ExternalDocumentationObject {
43
40
  description?: string;
44
41
  url: string;
45
42
  }
46
- export type FileChange = {
47
- author?: string;
48
- /** Date can be any
49
- * [parsable date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
50
- */
51
- date?: Date | string;
52
- };
53
- export type DocFrontMatter = {
54
- /**
55
- * The last part of the doc ID (will be refactored in the future to be the
56
- * full ID instead)
57
- * @see {@link DocMetadata.id}
58
- */
59
- id?: string;
60
- /**
61
- * Will override the default title collected from h1 heading.
62
- * @see {@link DocMetadata.title}
63
- */
64
- title?: string;
65
- /**
66
- * Front matter tags, unnormalized.
67
- * @see {@link DocMetadata.tags}
68
- */
69
- tags?: FrontMatterTag[];
70
- /**
71
- * If there isn't a Markdown h1 heading (which, if there is, we don't
72
- * remove), this front matter will cause the front matter title to not be
73
- * displayed in the doc page.
74
- */
75
- hide_title?: boolean;
76
- /** Hide the TOC on the right. */
77
- hide_table_of_contents?: boolean;
78
- /** Used in the head meta. */
79
- keywords?: string[];
80
- /** Used in the head meta. Should use `assets.image` in priority. */
81
- image?: string;
82
- /**
83
- * Will override the default excerpt.
84
- * @see {@link DocMetadata.description}
85
- */
86
- description?: string;
87
- /**
88
- * Custom slug appended after /<baseUrl>/<routeBasePath>/<versionPath>
89
- * @see {@link DocMetadata.slug}
90
- */
91
- slug?: string;
92
- /** Customizes the sidebar label for this doc. Will default to its title. */
93
- sidebar_label?: string;
94
- /**
95
- * Controls the position of a doc inside the generated sidebar slice when
96
- * using autogenerated sidebar items.
97
- *
98
- * @see https://docusaurus.io/docs/sidebar#autogenerated-sidebar-metadata
99
- */
100
- sidebar_position?: number;
101
- /**
102
- * Gives the corresponding sidebar label a special class name when using
103
- * autogenerated sidebars.
104
- */
105
- sidebar_class_name?: string;
106
- /**
107
- * Will be propagated to the final sidebars data structure. Useful if you
108
- * have swizzled sidebar-related code or simply querying doc data through
109
- * sidebars.
110
- */
111
- sidebar_custom_props?: {
112
- [key: string]: unknown;
113
- };
114
- /**
115
- * Changes the sidebar association of the current doc. Use `null` to make
116
- * the current doc not associated to any sidebar.
117
- */
118
- displayed_sidebar?: string | null;
119
- /**
120
- * Customizes the pagination label for this doc. Will default to the sidebar
121
- * label.
122
- */
123
- pagination_label?: string;
124
- /** Overrides the default URL computed for this doc. */
125
- custom_edit_url?: string | null;
126
- /**
127
- * Whether number prefix parsing is disabled on this doc.
128
- * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
129
- */
130
- parse_number_prefixes?: boolean;
131
- /**
132
- * Minimum TOC heading level. Must be between 2 and 6 and lower or equal to
133
- * the max value.
134
- */
135
- toc_min_heading_level?: number;
136
- /** Maximum TOC heading level. Must be between 2 and 6. */
137
- toc_max_heading_level?: number;
138
- /**
139
- * The ID of the documentation you want the "Next" pagination to link to.
140
- * Use `null` to disable showing "Next" for this page.
141
- * @see {@link DocMetadata.next}
142
- */
143
- pagination_next?: string | null;
144
- /**
145
- * The ID of the documentation you want the "Previous" pagination to link
146
- * to. Use `null` to disable showing "Previous" for this page.
147
- * @see {@link DocMetadata.prev}
148
- */
149
- pagination_prev?: string | null;
150
- /** Should this doc be excluded from production builds? */
151
- draft?: boolean;
152
- /** Allows overriding the last updated author and/or date. */
153
- last_update?: FileChange;
43
+ export interface DocFrontMatter extends DocusaurusDocFrontMatter {
154
44
  /** Provides OpenAPI Docs with a reference path to their respective Info Doc */
155
45
  info_path?: string;
156
- };
157
- export {};
46
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-theme-openapi-docs",
3
3
  "description": "OpenAPI theme for Docusaurus.",
4
- "version": "4.3.7",
4
+ "version": "4.5.0",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -35,8 +35,10 @@
35
35
  "@types/file-saver": "^2.0.5",
36
36
  "@types/lodash": "^4.14.176",
37
37
  "@types/pako": "^2.0.3",
38
+ "@types/postman-collection": "^3.5.11",
39
+ "@types/react-modal": "^3.16.3",
38
40
  "concurrently": "^5.2.0",
39
- "docusaurus-plugin-openapi-docs": "^4.3.7",
41
+ "docusaurus-plugin-openapi-docs": "^4.5.0",
40
42
  "docusaurus-plugin-sass": "^0.2.3",
41
43
  "eslint-plugin-prettier": "^5.0.1"
42
44
  },
@@ -79,5 +81,5 @@
79
81
  "engines": {
80
82
  "node": ">=14"
81
83
  },
82
- "gitHead": "e4d3ec4ebfb8415e97951076ce2f0901e8d88168"
84
+ "gitHead": "cb0ed6e02d7a963d51073e2bfd78d944fbb7ee34"
83
85
  }
@@ -96,7 +96,7 @@ export default function CodeBlockString({
96
96
  getLineProps={getLineProps}
97
97
  getTokenProps={getTokenProps}
98
98
  classNames={lineClassNames[i]}
99
- showLineNumbers={showLineNumbers}
99
+ showLineNumbers={!!showLineNumbers}
100
100
  />
101
101
  ))}
102
102
  </code>
@@ -122,9 +122,9 @@ export default function CodeBlockString({
122
122
  )}
123
123
  code={code}
124
124
  language={(language ?? "text") as Language}
125
- showLineNumbers={showLineNumbers}
125
+ showLineNumbers={!!showLineNumbers}
126
126
  blockClassName={blockClassName}
127
- title={title}
127
+ title={typeof title === "string" ? title : undefined}
128
128
  lineClassNames={lineClassNames}
129
129
  />
130
130
  </div>
@@ -7,11 +7,15 @@
7
7
 
8
8
  import React, { useCallback, useState, useRef, useEffect } from "react";
9
9
 
10
- import { CopyButtonProps } from "@docusaurus/theme-common/internal";
11
10
  import { translate } from "@docusaurus/Translate";
12
11
  import clsx from "clsx";
13
12
  import copy from "copy-text-to-clipboard";
14
13
 
14
+ interface CopyButtonProps {
15
+ code: string;
16
+ className?: string;
17
+ }
18
+
15
19
  export default function CopyButton({
16
20
  code,
17
21
  className,
@@ -237,8 +237,7 @@ function Body({
237
237
  try {
238
238
  // If the value is already valid JSON we shouldn't double encode the value
239
239
  JSON.parse(example.value);
240
- }
241
- catch (e) {
240
+ } catch (e) {
242
241
  body = JSON.stringify(example.value, null, 2);
243
242
  }
244
243
 
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import React, { useState, useEffect, type JSX } from "react";
8
+ import React, { useState, useEffect } from "react";
9
9
 
10
10
  import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
11
11
  import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
@@ -14,7 +14,7 @@ import CodeTabs from "@theme/ApiExplorer/CodeTabs";
14
14
  import { useTypedSelector } from "@theme/ApiItem/hooks";
15
15
  import cloneDeep from "lodash/cloneDeep";
16
16
  import codegen from "postman-code-generators";
17
- import sdk from "postman-collection";
17
+ import * as sdk from "postman-collection";
18
18
 
19
19
  import { CodeSample, Language } from "./code-snippets-types";
20
20
  import {
@@ -31,7 +31,7 @@ export interface Props {
31
31
  codeSamples: CodeSample[];
32
32
  }
33
33
 
34
- function CodeTab({ children, hidden, className }: any): JSX.Element {
34
+ function CodeTab({ children, hidden, className }: any): React.JSX.Element {
35
35
  return (
36
36
  <div role="tabpanel" className={className} {...{ hidden }}>
37
37
  {children}