docusaurus-theme-openapi-docs 0.0.0-1110 → 0.0.0-1151

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 (70) hide show
  1. package/lib/index.js +2 -0
  2. package/lib/theme/ApiExplorer/Accept/index.js +2 -1
  3. package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
  4. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +3 -1
  5. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +61 -29
  6. package/lib/theme/ApiExplorer/Body/index.js +4 -6
  7. package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
  8. package/lib/theme/ApiExplorer/ContentType/index.js +2 -1
  9. package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  10. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
  11. package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
  12. package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  13. package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
  14. package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
  15. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
  16. package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
  17. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
  18. package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
  19. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
  20. package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
  21. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
  22. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
  23. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
  24. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
  25. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
  26. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -1
  27. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
  28. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +4 -1
  29. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
  30. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +4 -1
  31. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  32. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +5 -0
  33. package/lib/theme/ApiExplorer/ParamOptions/index.js +27 -3
  34. package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
  35. package/lib/theme/ApiExplorer/Request/index.js +10 -4
  36. package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
  37. package/lib/theme/ApiExplorer/Response/index.js +2 -1
  38. package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
  39. package/lib/theme/ApiExplorer/Server/index.js +6 -3
  40. package/lib/theme/ApiItem/index.js +1 -1
  41. package/lib/theme/styles.scss +1 -0
  42. package/package.json +4 -3
  43. package/src/index.ts +2 -0
  44. package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
  45. package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
  46. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +44 -26
  47. package/src/theme/ApiExplorer/Body/index.tsx +7 -8
  48. package/src/theme/ApiExplorer/ContentType/index.tsx +2 -1
  49. package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
  50. package/src/theme/ApiExplorer/FormItem/index.tsx +2 -16
  51. package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
  52. package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
  53. package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
  54. package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
  55. package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
  56. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
  57. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
  58. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -1
  59. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -1
  60. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +12 -1
  61. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
  62. package/src/theme/ApiExplorer/ParamOptions/index.tsx +65 -9
  63. package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
  64. package/src/theme/ApiExplorer/Request/index.tsx +12 -7
  65. package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
  66. package/src/theme/ApiExplorer/Response/index.tsx +3 -2
  67. package/src/theme/ApiExplorer/Server/index.tsx +10 -3
  68. package/src/theme/ApiItem/index.tsx +1 -1
  69. package/src/theme/styles.scss +1 -0
  70. package/tsconfig.tsbuildinfo +1 -1
@@ -23,7 +23,7 @@ const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
23
23
  const hooks_1 = require("@theme/ApiItem/hooks");
24
24
  const translationIds_1 = require("@theme/translationIds");
25
25
  const react_hook_form_1 = require("react-hook-form");
26
- function ParamMultiSelectFormItem({ param }) {
26
+ function ParamMultiSelectFormItem({ param, label, type, required }) {
27
27
  const {
28
28
  control,
29
29
  formState: { errors },
@@ -78,6 +78,9 @@ function ParamMultiSelectFormItem({ param }) {
78
78
  name: "paramMultiSelect",
79
79
  render: ({ field: { onChange } }) =>
80
80
  react_1.default.createElement(FormMultiSelect_1.default, {
81
+ label: label,
82
+ type: type,
83
+ required: required,
81
84
  options: options,
82
85
  onChange: (e) => handleChange(e, onChange),
83
86
  showErrors: !!showErrorMessage,
@@ -2,5 +2,8 @@ import React from "react";
2
2
  import { Param } from "@theme/ApiExplorer/ParamOptions/slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
+ label?: string;
6
+ type?: string;
7
+ required?: boolean;
5
8
  }
6
- export default function ParamSelectFormItem({ param }: ParamProps): React.JSX.Element;
9
+ export default function ParamSelectFormItem({ param, label, type, required, }: ParamProps): React.JSX.Element;
@@ -21,7 +21,7 @@ const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
21
21
  const hooks_1 = require("@theme/ApiItem/hooks");
22
22
  const translationIds_1 = require("@theme/translationIds");
23
23
  const react_hook_form_1 = require("react-hook-form");
24
- function ParamSelectFormItem({ param }) {
24
+ function ParamSelectFormItem({ param, label, type, required }) {
25
25
  const {
26
26
  control,
27
27
  formState: { errors },
@@ -45,6 +45,9 @@ function ParamSelectFormItem({ param }) {
45
45
  name: "paramSelect",
46
46
  render: ({ field: { onChange } }) =>
47
47
  react_1.default.createElement(FormSelect_1.default, {
48
+ label: label,
49
+ type: type,
50
+ required: required,
48
51
  options: ["---", ...options],
49
52
  onChange: (e) => {
50
53
  const val = e.target.value;
@@ -2,5 +2,8 @@ import React from "react";
2
2
  import { Param } from "@theme/ApiExplorer/ParamOptions/slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
+ label?: string;
6
+ type?: string;
7
+ required?: boolean;
5
8
  }
6
- export default function ParamTextFormItem({ param }: ParamProps): React.JSX.Element;
9
+ export default function ParamTextFormItem({ param, label, type, required, }: ParamProps): React.JSX.Element;
@@ -18,9 +18,12 @@ const FormTextInput_1 = __importDefault(
18
18
  );
19
19
  const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
20
20
  const hooks_1 = require("@theme/ApiItem/hooks");
21
- function ParamTextFormItem({ param }) {
21
+ function ParamTextFormItem({ param, label, type, required }) {
22
22
  const dispatch = (0, hooks_1.useTypedDispatch)();
23
23
  return react_1.default.createElement(FormTextInput_1.default, {
24
+ label: label,
25
+ type: type,
26
+ required: required,
24
27
  isRequired: param.required,
25
28
  paramName: param.name,
26
29
  placeholder: param.description || param.name,
@@ -63,15 +63,10 @@
63
63
  margin-top: calc(var(--ifm-pre-padding) / 2);
64
64
  background-color: var(--openapi-input-background);
65
65
  border: none;
66
- outline: none;
67
66
  color: var(--ifm-pre-color);
68
67
  border-radius: 4px;
69
68
  margin-left: 4px;
70
69
 
71
- &:focus {
72
- outline: 0;
73
- }
74
-
75
70
  &:active {
76
71
  box-shadow: inset 0px 0px 0px 2px var(--openapi-input-border);
77
72
  }
@@ -102,10 +97,6 @@
102
97
  background-color: var(--openapi-input-border);
103
98
  }
104
99
 
105
- &:focus {
106
- outline: 0;
107
- }
108
-
109
100
  &:active {
110
101
  box-shadow:
111
102
  inset 0 0 0 1px var(--openapi-input-border),
@@ -1,5 +1,10 @@
1
1
  import React from "react";
2
2
  import { Param } from "./slice";
3
+ export interface LabelProps {
4
+ label?: string;
5
+ type?: string;
6
+ required?: boolean;
7
+ }
3
8
  export interface ParamProps {
4
9
  param: Param;
5
10
  }
@@ -107,44 +107,65 @@ function getSchemaEnum(schema) {
107
107
  }
108
108
  return undefined;
109
109
  }
110
- function ParamOption({ param }) {
110
+ function ParamOption({ param, label, type, required }) {
111
111
  const schemaEnum = getSchemaEnum(param.schema);
112
112
  const itemsEnum = getSchemaEnum(param.schema?.items);
113
113
  if (param.schema?.type === "array" && itemsEnum) {
114
114
  return react_1.default.createElement(ParamMultiSelectFormItem_1.default, {
115
115
  param: param,
116
+ label: label,
117
+ type: type,
118
+ required: required,
116
119
  });
117
120
  }
118
121
  if (param.schema?.type === "array") {
119
122
  return react_1.default.createElement(ParamArrayFormItem_1.default, {
120
123
  param: param,
124
+ label: label,
125
+ type: type,
126
+ required: required,
121
127
  });
122
128
  }
123
129
  if (schemaEnum) {
124
130
  return react_1.default.createElement(ParamSelectFormItem_1.default, {
125
131
  param: param,
132
+ label: label,
133
+ type: type,
134
+ required: required,
126
135
  });
127
136
  }
128
137
  if (param.schema?.type === "boolean") {
129
138
  return react_1.default.createElement(ParamBooleanFormItem_1.default, {
130
139
  param: param,
140
+ label: label,
141
+ type: type,
142
+ required: required,
131
143
  });
132
144
  }
133
145
  // integer, number, string, int32, int64, float, double, object, byte, binary,
134
146
  // date-time, date, password
135
147
  return react_1.default.createElement(ParamTextFormItem_1.default, {
136
148
  param: param,
149
+ label: label,
150
+ type: type,
151
+ required: required,
137
152
  });
138
153
  }
139
154
  function ParamOptionWrapper({ param }) {
140
155
  return react_1.default.createElement(
141
156
  FormItem_1.default,
142
- { label: param.name, type: param.in, required: param.required },
143
- react_1.default.createElement(ParamOption, { param: param })
157
+ null,
158
+ react_1.default.createElement(ParamOption, {
159
+ param: param,
160
+ label: param.name,
161
+ type: param.in,
162
+ required: param.required,
163
+ })
144
164
  );
145
165
  }
146
166
  function ParamOptions() {
147
167
  const [showOptional, setShowOptional] = (0, react_1.useState)(false);
168
+ const optionalId = (0, react_1.useId)();
148
169
  const pathParams = (0, hooks_1.useTypedSelector)(
149
170
  (state) => state.params.path
150
171
  );
@@ -183,6 +204,8 @@ function ParamOptions() {
183
204
  {
184
205
  type: "button",
185
206
  className: "openapi-explorer__show-more-btn",
207
+ "aria-expanded": showOptional,
208
+ "aria-controls": optionalId,
186
209
  onClick: () => setShowOptional((prev) => !prev),
187
210
  },
188
211
  react_1.default.createElement(
@@ -241,6 +264,7 @@ function ParamOptions() {
241
264
  className: showOptional
242
265
  ? "openapi-explorer__show-options"
243
266
  : "openapi-explorer__hide-options",
267
+ id: optionalId,
244
268
  },
245
269
  optionalParams.map((param) =>
246
270
  react_1.default.createElement(ParamOptionWrapper, {
@@ -48,6 +48,17 @@
48
48
  }
49
49
 
50
50
  .openapi-explorer__expand-details-btn {
51
+ -webkit-appearance: none;
52
+ -moz-appearance: none;
53
+ appearance: none;
54
+ padding: 0;
55
+ cursor: pointer;
56
+ border: 0px solid transparent;
57
+ background-color: transparent;
58
+ text-transform: inherit;
59
+ font-weight: inherit;
60
+ font-size: inherit;
61
+
51
62
  &:hover {
52
63
  cursor: pointer;
53
64
  }
@@ -140,6 +140,7 @@ function Request({ item }) {
140
140
  const [expandBody, setExpandBody] = (0, react_1.useState)(true);
141
141
  const [expandParams, setExpandParams] = (0, react_1.useState)(true);
142
142
  const [expandServer, setExpandServer] = (0, react_1.useState)(true);
143
+ const serverLabelId = (0, react_1.useId)();
143
144
  const allParams = [
144
145
  ...pathParams,
145
146
  ...queryParams,
@@ -167,7 +168,7 @@ function Request({ item }) {
167
168
  item.parameters?.forEach((param) => {
168
169
  const paramType = param.in;
169
170
  const paramsArray = paramsObject[paramType];
170
- paramsArray.push(param);
171
+ paramsArray?.push(param);
171
172
  });
172
173
  const methods = (0, react_hook_form_1.useForm)({ shouldFocusError: false });
173
174
  const handleEventStream = async (res) => {
@@ -313,8 +314,9 @@ function Request({ item }) {
313
314
  ),
314
315
  allDetailsExpanded
315
316
  ? react_1.default.createElement(
316
- "span",
317
+ "button",
317
318
  {
319
+ type: "button",
318
320
  className: "openapi-explorer__expand-details-btn",
319
321
  onClick: collapseAllDetails,
320
322
  },
@@ -324,8 +326,9 @@ function Request({ item }) {
324
326
  })
325
327
  )
326
328
  : react_1.default.createElement(
327
- "span",
329
+ "button",
328
330
  {
331
+ type: "button",
329
332
  className: "openapi-explorer__expand-details-btn",
330
333
  onClick: expandAllDetails,
331
334
  },
@@ -349,6 +352,7 @@ function Request({ item }) {
349
352
  react_1.default.createElement(
350
353
  "summary",
351
354
  {
355
+ id: serverLabelId,
352
356
  className: "openapi-explorer__details-summary",
353
357
  onClick: (e) => {
354
358
  e.preventDefault();
@@ -360,7 +364,9 @@ function Request({ item }) {
360
364
  message: "Base URL",
361
365
  })
362
366
  ),
363
- react_1.default.createElement(Server_1.default, null)
367
+ react_1.default.createElement(Server_1.default, {
368
+ labelId: serverLabelId,
369
+ })
364
370
  ),
365
371
  showAuth &&
366
372
  react_1.default.createElement(
@@ -43,6 +43,17 @@
43
43
  }
44
44
 
45
45
  .openapi-explorer__response-clear-btn {
46
+ -webkit-appearance: none;
47
+ -moz-appearance: none;
48
+ appearance: none;
49
+ padding: 0;
50
+ cursor: pointer;
51
+ border: 0px solid transparent;
52
+ background-color: transparent;
53
+ text-transform: inherit;
54
+ font-weight: inherit;
55
+ font-size: inherit;
56
+
46
57
  &:hover {
47
58
  cursor: pointer;
48
59
  }
@@ -152,8 +152,9 @@ function Response({ item }) {
152
152
  })
153
153
  ),
154
154
  react_1.default.createElement(
155
- "span",
155
+ "button",
156
156
  {
157
+ type: "button",
157
158
  className: "openapi-explorer__response-clear-btn",
158
159
  onClick: () => {
159
160
  dispatch((0, slice_1.clearResponse)());
@@ -1,3 +1,6 @@
1
1
  import React from "react";
2
- declare function Server(): React.JSX.Element | null;
2
+ interface ServerProps {
3
+ labelId?: string;
4
+ }
5
+ declare function Server({ labelId }: ServerProps): React.JSX.Element | null;
3
6
  export default Server;
@@ -80,7 +80,7 @@ const FormTextInput_1 = __importDefault(
80
80
  const hooks_1 = require("@theme/ApiItem/hooks");
81
81
  const translationIds_1 = require("@theme/translationIds");
82
82
  const slice_1 = require("./slice");
83
- function Server() {
83
+ function Server({ labelId }) {
84
84
  const [isEditing, setIsEditing] = (0, react_1.useState)(false);
85
85
  const value = (0, hooks_1.useTypedSelector)((state) => state.server.value);
86
86
  const options = (0, hooks_1.useTypedSelector)(
@@ -154,6 +154,7 @@ function Server() {
154
154
  FormItem_1.default,
155
155
  null,
156
156
  react_1.default.createElement(FormSelect_1.default, {
157
+ ariaLabelledBy: labelId,
157
158
  options: options.map((s) => s.url),
158
159
  onChange: (e) => {
159
160
  dispatch(
@@ -177,8 +178,9 @@ function Server() {
177
178
  if (value.variables?.[key].enum !== undefined) {
178
179
  return react_1.default.createElement(
179
180
  FormItem_1.default,
180
- { label: key },
181
+ null,
181
182
  react_1.default.createElement(FormSelect_1.default, {
183
+ label: key,
182
184
  options: value.variables[key].enum,
183
185
  onChange: (e) => {
184
186
  dispatch(
@@ -193,8 +195,9 @@ function Server() {
193
195
  }
194
196
  return react_1.default.createElement(
195
197
  FormItem_1.default,
196
- { label: key },
198
+ null,
197
199
  react_1.default.createElement(FormTextInput_1.default, {
200
+ label: key,
198
201
  placeholder: value.variables?.[key].default,
199
202
  onChange: (e) => {
200
203
  dispatch(
@@ -100,7 +100,7 @@ function ApiItem(props) {
100
100
  api?.parameters?.forEach((param) => {
101
101
  const paramType = param.in;
102
102
  const paramsArray = params[paramType];
103
- paramsArray.push(param);
103
+ paramsArray?.push(param);
104
104
  });
105
105
  const auth = (0, slice_1.createAuth)({
106
106
  security: api?.security,
@@ -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";
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": "0.0.0-1110",
4
+ "version": "0.0.0-1151",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -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": "0.0.0-1110",
41
+ "docusaurus-plugin-openapi-docs": "0.0.0-1151",
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",
@@ -81,5 +82,5 @@
81
82
  "engines": {
82
83
  "node": ">=14"
83
84
  },
84
- "gitHead": "e4a99880178b660e4ba688b2d13aef1280752322"
85
+ "gitHead": "ce9f21391974edb2ad7a1a7c2e39700a27bc5123"
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: [
@@ -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))}
@@ -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 ?? ""}
@@ -8,6 +8,7 @@
8
8
  import React from "react";
9
9
 
10
10
  import FormFileUpload from "@theme/ApiExplorer/FormFileUpload";
11
+ import FormLabel from "@theme/ApiExplorer/FormLabel";
11
12
  import FormSelect from "@theme/ApiExplorer/FormSelect";
12
13
  import FormTextInput from "@theme/ApiExplorer/FormTextInput";
13
14
  import LiveApp from "@theme/ApiExplorer/LiveEditor";
@@ -21,12 +22,16 @@ interface FormBodyItemProps {
21
22
  schemaObject: SchemaObject;
22
23
  id: string;
23
24
  schema: SchemaObject;
25
+ label?: string;
26
+ required?: boolean;
24
27
  }
25
28
 
26
29
  export default function FormBodyItem({
27
30
  schemaObject,
28
31
  id,
29
32
  schema,
33
+ label,
34
+ required,
30
35
  }: FormBodyItemProps): React.JSX.Element {
31
36
  const dispatch = useTypedDispatch();
32
37
 
@@ -35,30 +40,36 @@ export default function FormBodyItem({
35
40
  schemaObject.items?.format === "binary"
36
41
  ) {
37
42
  return (
38
- <FileArrayFormBodyItem id={id} description={schemaObject.description} />
43
+ <>
44
+ {label && <FormLabel label={label} required={required} />}
45
+ <FileArrayFormBodyItem id={id} description={schemaObject.description} />
46
+ </>
39
47
  );
40
48
  }
41
49
 
42
50
  if (schemaObject.format === "binary") {
43
51
  return (
44
- <FormFileUpload
45
- placeholder={schemaObject.description || id}
46
- onChange={(file: any) => {
47
- if (file === undefined) {
48
- dispatch(clearFormBodyKey(id));
49
- return;
50
- }
51
- dispatch(
52
- setFileFormBody({
53
- key: id,
54
- value: {
55
- src: `/path/to/${file.name}`,
56
- content: file,
57
- },
58
- })
59
- );
60
- }}
61
- />
52
+ <>
53
+ {label && <FormLabel label={label} required={required} />}
54
+ <FormFileUpload
55
+ placeholder={schemaObject.description || id}
56
+ onChange={(file: any) => {
57
+ if (file === undefined) {
58
+ dispatch(clearFormBodyKey(id));
59
+ return;
60
+ }
61
+ dispatch(
62
+ setFileFormBody({
63
+ key: id,
64
+ value: {
65
+ src: `/path/to/${file.name}`,
66
+ content: file,
67
+ },
68
+ })
69
+ );
70
+ }}
71
+ />
72
+ </>
62
73
  );
63
74
  }
64
75
 
@@ -73,13 +84,16 @@ export default function FormBodyItem({
73
84
  );
74
85
 
75
86
  return (
76
- <LiveApp
77
- action={(code: string) =>
78
- dispatch(setStringFormBody({ key: id, value: code }))
79
- }
80
- >
81
- {objectExample}
82
- </LiveApp>
87
+ <>
88
+ {label && <FormLabel label={label} required={required} />}
89
+ <LiveApp
90
+ action={(code: string) =>
91
+ dispatch(setStringFormBody({ key: id, value: code }))
92
+ }
93
+ >
94
+ {objectExample}
95
+ </LiveApp>
96
+ </>
83
97
  );
84
98
  }
85
99
 
@@ -89,6 +103,8 @@ export default function FormBodyItem({
89
103
  ) {
90
104
  return (
91
105
  <FormSelect
106
+ label={label}
107
+ required={required}
92
108
  options={["---", ...schemaObject.enum]}
93
109
  onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
94
110
  const val = e.target.value;
@@ -109,6 +125,8 @@ export default function FormBodyItem({
109
125
  // TODO: support all the other types.
110
126
  return (
111
127
  <FormTextInput
128
+ label={label}
129
+ required={required}
112
130
  paramName={id}
113
131
  isRequired={
114
132
  Array.isArray(schema.required) && schema.required.includes(id)