docusaurus-theme-openapi-docs 4.7.1 → 5.0.1

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 (129) hide show
  1. package/lib/index.js +2 -0
  2. package/lib/markdown/schema.js +63 -9
  3. package/lib/theme/ApiExplorer/Accept/index.js +2 -1
  4. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +16 -5
  5. package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
  6. package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
  7. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +5 -1
  8. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +190 -37
  9. package/lib/theme/ApiExplorer/Body/index.js +84 -13
  10. package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
  11. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
  12. package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -0
  13. package/lib/theme/ApiExplorer/CodeTabs/index.js +15 -16
  14. package/lib/theme/ApiExplorer/ContentType/index.js +7 -2
  15. package/lib/theme/ApiExplorer/EncodingSelection/slice.d.ts +17 -0
  16. package/lib/theme/ApiExplorer/EncodingSelection/slice.js +29 -0
  17. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.d.ts +12 -0
  18. package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.js +39 -0
  19. package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  20. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
  21. package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
  22. package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  23. package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
  24. package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
  25. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
  26. package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
  27. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
  28. package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
  29. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
  30. package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
  31. package/lib/theme/ApiExplorer/MethodEndpoint/index.js +28 -0
  32. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
  33. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
  34. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
  35. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
  36. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
  37. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +6 -2
  38. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
  39. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +6 -2
  40. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
  41. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +8 -3
  42. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  43. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +10 -0
  44. package/lib/theme/ApiExplorer/ParamOptions/index.js +55 -5
  45. package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
  46. package/lib/theme/ApiExplorer/Request/index.js +19 -5
  47. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +3 -1
  48. package/lib/theme/ApiExplorer/Request/makeRequest.js +19 -3
  49. package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
  50. package/lib/theme/ApiExplorer/Response/index.js +98 -12
  51. package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
  52. package/lib/theme/ApiExplorer/Server/index.js +6 -3
  53. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +4 -1
  54. package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -5
  55. package/lib/theme/ApiExplorer/index.js +1 -0
  56. package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
  57. package/lib/theme/ApiItem/hooks.d.ts +1 -0
  58. package/lib/theme/ApiItem/index.js +2 -1
  59. package/lib/theme/ApiItem/store.d.ts +6 -0
  60. package/lib/theme/ApiItem/store.js +11 -7
  61. package/lib/theme/ApiTabs/index.js +10 -11
  62. package/lib/theme/DiscriminatorTabs/index.js +10 -11
  63. package/lib/theme/MimeTabs/index.js +10 -11
  64. package/lib/theme/OperationTabs/index.js +10 -11
  65. package/lib/theme/ParamsItem/index.js +27 -0
  66. package/lib/theme/RequestSchema/index.js +172 -109
  67. package/lib/theme/ResponseHeaders/index.js +0 -1
  68. package/lib/theme/Schema/index.d.ts +1 -1
  69. package/lib/theme/Schema/index.js +91 -23
  70. package/lib/theme/SchemaItem/index.js +6 -1
  71. package/lib/theme/SchemaTabs/index.d.ts +1 -1
  72. package/lib/theme/SchemaTabs/index.js +31 -12
  73. package/lib/theme/styles.scss +1 -0
  74. package/lib/theme/translationIds.d.ts +3 -0
  75. package/lib/theme/translationIds.js +3 -0
  76. package/package.json +9 -8
  77. package/src/index.ts +2 -0
  78. package/src/markdown/schema.ts +69 -13
  79. package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
  80. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.tsx +15 -3
  81. package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
  82. package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +0 -5
  83. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +115 -37
  84. package/src/theme/ApiExplorer/Body/index.tsx +85 -17
  85. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +9 -1
  86. package/src/theme/ApiExplorer/CodeTabs/index.tsx +19 -19
  87. package/src/theme/ApiExplorer/ContentType/index.tsx +7 -4
  88. package/src/theme/ApiExplorer/EncodingSelection/slice.ts +31 -0
  89. package/src/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.ts +43 -0
  90. package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  91. package/src/theme/ApiExplorer/FormItem/index.tsx +2 -16
  92. package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  93. package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
  94. package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
  95. package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
  96. package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
  97. package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +21 -0
  98. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
  99. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
  100. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +14 -2
  101. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
  102. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +16 -3
  103. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  104. package/src/theme/ApiExplorer/ParamOptions/index.tsx +97 -11
  105. package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
  106. package/src/theme/ApiExplorer/Request/index.tsx +20 -8
  107. package/src/theme/ApiExplorer/Request/makeRequest.ts +19 -3
  108. package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
  109. package/src/theme/ApiExplorer/Response/index.tsx +35 -14
  110. package/src/theme/ApiExplorer/Server/index.tsx +10 -3
  111. package/src/theme/ApiExplorer/buildPostmanRequest.ts +52 -5
  112. package/src/theme/ApiExplorer/index.tsx +1 -0
  113. package/src/theme/ApiItem/index.tsx +2 -1
  114. package/src/theme/ApiItem/store.ts +2 -0
  115. package/src/theme/ApiTabs/index.tsx +14 -19
  116. package/src/theme/DiscriminatorTabs/index.tsx +14 -19
  117. package/src/theme/MimeTabs/index.tsx +15 -19
  118. package/src/theme/OperationTabs/index.tsx +14 -19
  119. package/src/theme/ParamsItem/index.tsx +25 -0
  120. package/src/theme/RequestSchema/index.tsx +141 -83
  121. package/src/theme/ResponseHeaders/index.tsx +1 -2
  122. package/src/theme/Schema/index.tsx +112 -27
  123. package/src/theme/SchemaItem/index.tsx +6 -1
  124. package/src/theme/SchemaTabs/index.tsx +42 -21
  125. package/src/theme/styles.scss +1 -0
  126. package/src/theme/translationIds.ts +3 -0
  127. package/src/theme-classic.d.ts +25 -1
  128. package/src/types.d.ts +7 -0
  129. package/tsconfig.tsbuildinfo +1 -1
@@ -233,25 +233,44 @@ function TabContent({ lazy, children, selectedValue }) {
233
233
  return react_1.default.createElement(
234
234
  "div",
235
235
  { className: "margin-top--md" },
236
- childTabs.map((tabItem, i) =>
237
- (0, react_1.cloneElement)(tabItem, {
238
- key: i,
239
- hidden: tabItem.props.value !== selectedValue,
240
- })
241
- )
236
+ childTabs
242
237
  );
243
238
  }
244
239
  function TabsComponent(props) {
245
- const tabs = (0, internal_1.useTabs)(props);
240
+ const tabs = (0, internal_1.useTabsContextValue)(props);
246
241
  return react_1.default.createElement(
247
- "div",
248
- { className: "openapi-tabs__schema-container" },
249
- react_1.default.createElement(TabList, { ...props, ...tabs }),
250
- react_1.default.createElement(TabContent, { ...props, ...tabs })
242
+ internal_1.TabsProvider,
243
+ { value: tabs },
244
+ react_1.default.createElement(
245
+ "div",
246
+ { className: "openapi-tabs__schema-container" },
247
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
248
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
249
+ )
251
250
  );
252
251
  }
253
252
  function SchemaTabs(props) {
254
253
  const isBrowser = (0, useIsBrowser_1.default)();
254
+ const children = Array.isArray(props.children)
255
+ ? props.children.filter(Boolean)
256
+ : props.children
257
+ ? [props.children]
258
+ : [];
259
+ if (children.length === 0) {
260
+ return null;
261
+ }
262
+ let sanitizedChildren;
263
+ try {
264
+ sanitizedChildren = (0, internal_1.sanitizeTabsChildren)(children);
265
+ } catch {
266
+ return null;
267
+ }
268
+ if (
269
+ !sanitizedChildren ||
270
+ (Array.isArray(sanitizedChildren) && sanitizedChildren.length === 0)
271
+ ) {
272
+ return null;
273
+ }
255
274
  return react_1.default.createElement(
256
275
  TabsComponent,
257
276
  // Remount tabs after hydration
@@ -262,6 +281,6 @@ function SchemaTabs(props) {
262
281
  key: String(isBrowser),
263
282
  ...props,
264
283
  },
265
- (0, internal_1.sanitizeTabsChildren)(props.children)
284
+ sanitizedChildren
266
285
  );
267
286
  }
@@ -9,6 +9,7 @@
9
9
  @use "./ApiExplorer/FloatingButton/FloatingButton";
10
10
  @use "./ApiExplorer/FormFileUpload/FormFileUpload";
11
11
  @use "./ApiExplorer/FormItem/FormItem";
12
+ @use "./ApiExplorer/FormLabel/FormLabel";
12
13
  @use "./ApiExplorer/FormMultiSelect/FormMultiSelect";
13
14
  @use "./ApiExplorer/FormSelect/FormSelect";
14
15
  @use "./ApiExplorer/FormTextInput/FormTextInput";
@@ -60,6 +60,8 @@ export declare const OPENAPI_SCHEMA: {
60
60
  NO_SCHEMA: string;
61
61
  };
62
62
  export declare const OPENAPI_SCHEMA_ITEM: {
63
+ CHARACTERS: string;
64
+ NON_EMPTY: string;
63
65
  REQUIRED: string;
64
66
  DEPRECATED: string;
65
67
  NULLABLE: string;
@@ -71,6 +73,7 @@ export declare const OPENAPI_SCHEMA_ITEM: {
71
73
  ENUM_VALUE: string;
72
74
  ENUM_DESCRIPTION: string;
73
75
  POSSIBLE_VALUES: string;
76
+ EXPRESSION: string;
74
77
  ONE_OF: string;
75
78
  ANY_OF: string;
76
79
  };
@@ -84,6 +84,8 @@ exports.OPENAPI_SCHEMA = {
84
84
  NO_SCHEMA: "theme.openapi.schema.noSchema",
85
85
  };
86
86
  exports.OPENAPI_SCHEMA_ITEM = {
87
+ CHARACTERS: "theme.openapi.schemaItem.characters",
88
+ NON_EMPTY: "theme.openapi.schemaItem.nonEmpty",
87
89
  REQUIRED: "theme.openapi.schemaItem.required",
88
90
  DEPRECATED: "theme.openapi.schemaItem.deprecated",
89
91
  NULLABLE: "theme.openapi.schemaItem.nullable",
@@ -95,6 +97,7 @@ exports.OPENAPI_SCHEMA_ITEM = {
95
97
  ENUM_VALUE: "theme.openapi.schemaItem.enumValue",
96
98
  ENUM_DESCRIPTION: "theme.openapi.schemaItem.enumDescription",
97
99
  POSSIBLE_VALUES: "theme.openapi.schemaItem.possibleValues",
100
+ EXPRESSION: "theme.openapi.schemaItem.expression",
98
101
  ONE_OF: "theme.openapi.schemaItem.oneOf",
99
102
  ANY_OF: "theme.openapi.schemaItem.anyOf",
100
103
  };
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.7.1",
4
+ "version": "5.0.1",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -28,9 +28,9 @@
28
28
  "watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\""
29
29
  },
30
30
  "devDependencies": {
31
- "@docusaurus/theme-classic": "^3.5.0",
32
- "@docusaurus/theme-common": "^3.5.0",
33
- "@docusaurus/types": "^3.5.0",
31
+ "@docusaurus/theme-classic": "^3.10.0",
32
+ "@docusaurus/theme-common": "^3.10.0",
33
+ "@docusaurus/types": "^3.10.0",
34
34
  "@types/crypto-js": "^4.2.2",
35
35
  "@types/file-saver": "^2.0.7",
36
36
  "@types/lodash": "^4.17.20",
@@ -38,7 +38,7 @@
38
38
  "@types/postman-collection": "^3.5.11",
39
39
  "@types/react-modal": "^3.16.3",
40
40
  "concurrently": "^9.2.0",
41
- "docusaurus-plugin-openapi-docs": "^4.7.1",
41
+ "docusaurus-plugin-openapi-docs": "^5.0.1",
42
42
  "docusaurus-plugin-sass": "^0.2.6",
43
43
  "eslint-plugin-prettier": "^5.5.1"
44
44
  },
@@ -53,6 +53,7 @@
53
53
  "file-saver": "^2.0.5",
54
54
  "lodash": "^4.17.21",
55
55
  "pako": "^2.1.0",
56
+ "path-browserify": "^1.0.1",
56
57
  "postman-code-generators": "^2.0.0",
57
58
  "postman-collection": "^5.0.2",
58
59
  "prism-react-renderer": "^2.4.1",
@@ -72,8 +73,8 @@
72
73
  "xml-formatter": "^3.6.6"
73
74
  },
74
75
  "peerDependencies": {
75
- "@docusaurus/theme-common": "^3.5.0",
76
- "docusaurus-plugin-openapi-docs": "^4.0.0",
76
+ "@docusaurus/theme-common": "^3.10.0",
77
+ "docusaurus-plugin-openapi-docs": "^5.0.0",
77
78
  "docusaurus-plugin-sass": "^0.2.3",
78
79
  "react": "^16.8.4 || ^17.0.0 || ^18.0.0 || ^19.0.0",
79
80
  "react-dom": "^16.8.4 || ^17.0.0 || ^18.0.0 || ^19.0.0"
@@ -81,5 +82,5 @@
81
82
  "engines": {
82
83
  "node": ">=14"
83
84
  },
84
- "gitHead": "0a89b9db05458cff9591eb065160e26c05f64a18"
85
+ "gitHead": "467fb6d5e1e78e0fd2ce5aaa2904aef701fe87e3"
85
86
  }
package/src/index.ts CHANGED
@@ -42,6 +42,7 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
42
42
  resolve: {
43
43
  fallback: {
44
44
  buffer: require.resolve("buffer/"),
45
+ path: require.resolve("path-browserify"),
45
46
  },
46
47
  },
47
48
  plugins: [
@@ -71,6 +72,7 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
71
72
  resolve: {
72
73
  fallback: {
73
74
  buffer: require.resolve("buffer/"),
75
+ path: require.resolve("path-browserify"),
74
76
  },
75
77
  },
76
78
  plugins: [
@@ -10,6 +10,44 @@ import { translate } from "@docusaurus/Translate";
10
10
  import { OPENAPI_SCHEMA_ITEM } from "../theme/translationIds";
11
11
  import { SchemaObject } from "../types";
12
12
 
13
+ /**
14
+ * Extracts enum values from a schema, including when wrapped in allOf.
15
+ */
16
+ function getEnumFromSchema(schema: SchemaObject): any[] | undefined {
17
+ if (schema.enum) {
18
+ return schema.enum;
19
+ }
20
+
21
+ if (schema.allOf && Array.isArray(schema.allOf)) {
22
+ for (const item of schema.allOf) {
23
+ if (item.enum) {
24
+ return item.enum;
25
+ }
26
+ }
27
+ }
28
+
29
+ return undefined;
30
+ }
31
+
32
+ /**
33
+ * Extracts the type from a schema, including when wrapped in allOf.
34
+ */
35
+ function getTypeFromSchema(schema: SchemaObject): string | undefined {
36
+ if (schema.type) {
37
+ return schema.type as string;
38
+ }
39
+
40
+ if (schema.allOf && Array.isArray(schema.allOf)) {
41
+ for (const item of schema.allOf) {
42
+ if (item.type) {
43
+ return item.type as string;
44
+ }
45
+ }
46
+ }
47
+
48
+ return undefined;
49
+ }
50
+
13
51
  function prettyName(schema: SchemaObject, circular?: boolean) {
14
52
  // Handle enum-only schemas (valid in JSON Schema)
15
53
  // When enum is present without explicit type, treat as string
@@ -28,6 +66,12 @@ function prettyName(schema: SchemaObject, circular?: boolean) {
28
66
  return schema.allOf[0];
29
67
  }
30
68
  }
69
+ // Check if allOf contains an enum - if so, return the type from allOf
70
+ const enumFromAllOf = getEnumFromSchema(schema);
71
+ if (enumFromAllOf) {
72
+ const typeFromAllOf = getTypeFromSchema(schema);
73
+ return typeFromAllOf ?? "string";
74
+ }
31
75
  return "object";
32
76
  }
33
77
 
@@ -92,11 +136,11 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
92
136
 
93
137
  let qualifierGroups = [];
94
138
 
95
- if (schema.items && schema.items.enum) {
96
- if (schema.items.enum) {
97
- qualifierGroups.push(
98
- `[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`
99
- );
139
+ // Check for enum in array items (directly or inside allOf)
140
+ if (schema.items) {
141
+ const itemsEnum = getEnumFromSchema(schema.items as SchemaObject);
142
+ if (itemsEnum) {
143
+ qualifierGroups.push(`[${itemsEnum.map((e) => `\`${e}\``).join(", ")}]`);
100
144
  }
101
145
  }
102
146
 
@@ -104,14 +148,22 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
104
148
  let lengthQualifier = "";
105
149
  let minLength;
106
150
  let maxLength;
151
+ const charactersMessage = translate({
152
+ id: OPENAPI_SCHEMA_ITEM.CHARACTERS,
153
+ message: "characters",
154
+ });
155
+ const nonEmptyMessage = translate({
156
+ id: OPENAPI_SCHEMA_ITEM.NON_EMPTY,
157
+ message: "non-empty",
158
+ });
107
159
  if (schema.minLength && schema.minLength > 1) {
108
- minLength = `\`>= ${schema.minLength} characters\``;
160
+ minLength = `\`>= ${schema.minLength} ${charactersMessage}\``;
109
161
  }
110
162
  if (schema.minLength && schema.minLength === 1) {
111
- minLength = `\`non-empty\``;
163
+ minLength = `\`${nonEmptyMessage}\``;
112
164
  }
113
165
  if (schema.maxLength) {
114
- maxLength = `\`<= ${schema.maxLength} characters\``;
166
+ maxLength = `\`<= ${schema.maxLength} ${charactersMessage}\``;
115
167
  }
116
168
 
117
169
  if (minLength && !maxLength) {
@@ -165,9 +217,11 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
165
217
  }
166
218
 
167
219
  if (schema.pattern) {
168
- qualifierGroups.push(
169
- `Value must match regular expression \`${schema.pattern}\``
170
- );
220
+ const expressionMessage = translate({
221
+ id: OPENAPI_SCHEMA_ITEM.EXPRESSION,
222
+ message: "Value must match regular expression",
223
+ });
224
+ qualifierGroups.push(`${expressionMessage} \`${schema.pattern}\``);
171
225
  }
172
226
 
173
227
  // Check if discriminator mapping
@@ -177,8 +231,10 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
177
231
  qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
178
232
  }
179
233
 
180
- if (schema.enum) {
181
- qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
234
+ // Check for enum directly on schema or inside allOf
235
+ const schemaEnum = getEnumFromSchema(schema);
236
+ if (schemaEnum) {
237
+ qualifierGroups.push(`[${schemaEnum.map((e) => `\`${e}\``).join(", ")}]`);
182
238
  }
183
239
 
184
240
  if (schema.minItems) {
@@ -23,8 +23,9 @@ function Accept() {
23
23
  }
24
24
 
25
25
  return (
26
- <FormItem label="Accept">
26
+ <FormItem>
27
27
  <FormSelect
28
+ label="Accept"
28
29
  value={value}
29
30
  options={options}
30
31
  onChange={(e: any) => dispatch(setAccept(e.target.value))}
@@ -9,21 +9,33 @@ import React, { useCallback, useState, useRef, useEffect } from "react";
9
9
 
10
10
  import { translate } from "@docusaurus/Translate";
11
11
  import clsx from "clsx";
12
- import copy from "copy-text-to-clipboard";
13
12
 
14
13
  interface CopyButtonProps {
15
14
  code: string;
16
15
  className?: string;
17
16
  }
18
17
 
18
+ async function copyToClipboard(text: string) {
19
+ // The clipboard API is only defined in secure contexts (HTTPS / localhost).
20
+ // See https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
21
+ if (navigator.clipboard) {
22
+ return navigator.clipboard.writeText(text);
23
+ }
24
+ // Fall back to copy-text-to-clipboard for non-secure contexts (e.g. HTTP
25
+ // on a local network). The fallback is lazily loaded to avoid bundle
26
+ // overhead for the common HTTPS case.
27
+ const { default: copy } = await import("copy-text-to-clipboard");
28
+ return copy(text);
29
+ }
30
+
19
31
  export default function CopyButton({
20
32
  code,
21
33
  className,
22
34
  }: CopyButtonProps): React.JSX.Element {
23
35
  const [isCopied, setIsCopied] = useState(false);
24
36
  const copyTimeout = useRef<number | undefined>(undefined);
25
- const handleCopyCode = useCallback(() => {
26
- copy(code);
37
+ const handleCopyCode = useCallback(async () => {
38
+ await copyToClipboard(code);
27
39
  setIsCopied(true);
28
40
  copyTimeout.current = window.setTimeout(() => {
29
41
  setIsCopied(false);
@@ -34,13 +34,12 @@ function Authorization() {
34
34
  return (
35
35
  <div>
36
36
  {optionKeys.length > 1 && (
37
- <FormItem
38
- label={translate({
39
- id: OPENAPI_AUTH.SECURITY_SCHEME,
40
- message: "Security Scheme",
41
- })}
42
- >
37
+ <FormItem>
43
38
  <FormSelect
39
+ label={translate({
40
+ id: OPENAPI_AUTH.SECURITY_SCHEME,
41
+ message: "Security Scheme",
42
+ })}
44
43
  options={optionKeys}
45
44
  value={selected}
46
45
  onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
@@ -52,14 +51,12 @@ function Authorization() {
52
51
  {selectedAuth.map((a: any) => {
53
52
  if (a.type === "http" && a.scheme === "bearer") {
54
53
  return (
55
- <FormItem
56
- label={translate({
57
- id: OPENAPI_AUTH.BEARER_TOKEN,
58
- message: "Bearer Token",
59
- })}
60
- key={a.key + "-bearer"}
61
- >
54
+ <FormItem key={a.key + "-bearer"}>
62
55
  <FormTextInput
56
+ label={translate({
57
+ id: OPENAPI_AUTH.BEARER_TOKEN,
58
+ message: "Bearer Token",
59
+ })}
63
60
  placeholder={translate({
64
61
  id: OPENAPI_AUTH.BEARER_TOKEN,
65
62
  message: "Bearer Token",
@@ -83,14 +80,12 @@ function Authorization() {
83
80
 
84
81
  if (a.type === "oauth2") {
85
82
  return (
86
- <FormItem
87
- label={translate({
88
- id: OPENAPI_AUTH.BEARER_TOKEN,
89
- message: "Bearer Token",
90
- })}
91
- key={a.key + "-oauth2"}
92
- >
83
+ <FormItem key={a.key + "-oauth2"}>
93
84
  <FormTextInput
85
+ label={translate({
86
+ id: OPENAPI_AUTH.BEARER_TOKEN,
87
+ message: "Bearer Token",
88
+ })}
94
89
  placeholder={translate({
95
90
  id: OPENAPI_AUTH.BEARER_TOKEN,
96
91
  message: "Bearer Token",
@@ -115,13 +110,12 @@ function Authorization() {
115
110
  if (a.type === "http" && a.scheme === "basic") {
116
111
  return (
117
112
  <React.Fragment key={a.key + "-basic"}>
118
- <FormItem
119
- label={translate({
120
- id: OPENAPI_AUTH.USERNAME,
121
- message: "Username",
122
- })}
123
- >
113
+ <FormItem>
124
114
  <FormTextInput
115
+ label={translate({
116
+ id: OPENAPI_AUTH.USERNAME,
117
+ message: "Username",
118
+ })}
125
119
  placeholder={translate({
126
120
  id: OPENAPI_AUTH.USERNAME,
127
121
  message: "Username",
@@ -139,13 +133,12 @@ function Authorization() {
139
133
  }}
140
134
  />
141
135
  </FormItem>
142
- <FormItem
143
- label={translate({
144
- id: OPENAPI_AUTH.PASSWORD,
145
- message: "Password",
146
- })}
147
- >
136
+ <FormItem>
148
137
  <FormTextInput
138
+ label={translate({
139
+ id: OPENAPI_AUTH.PASSWORD,
140
+ message: "Password",
141
+ })}
149
142
  placeholder={translate({
150
143
  id: OPENAPI_AUTH.PASSWORD,
151
144
  message: "Password",
@@ -170,8 +163,9 @@ function Authorization() {
170
163
 
171
164
  if (a.type === "apiKey") {
172
165
  return (
173
- <FormItem label={`${a.key}`} key={a.key + "-apikey"}>
166
+ <FormItem key={a.key + "-apikey"}>
174
167
  <FormTextInput
168
+ label={`${a.key}`}
175
169
  placeholder={`${a.key}`}
176
170
  password
177
171
  value={data[a.key].apiKey ?? ""}
@@ -43,11 +43,6 @@ export default function FileArrayFormBodyItem({
43
43
  return;
44
44
  }
45
45
 
46
- let maxIndex = 0;
47
-
48
- newItems.keys().forEach((item) => {
49
- maxIndex = item > maxIndex ? item : maxIndex;
50
- });
51
46
  newItems.set(index, {
52
47
  src: `/path/to/${file.name}`,
53
48
  content: file,