docusaurus-theme-openapi-docs 0.0.0-1110 → 0.0.0-1130
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.
- package/lib/index.js +2 -0
- package/lib/theme/ApiExplorer/Accept/index.js +2 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +3 -1
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +61 -29
- package/lib/theme/ApiExplorer/Body/index.js +4 -6
- package/lib/theme/ApiExplorer/ContentType/index.js +2 -1
- package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
- package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
- package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
- package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
- package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
- package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +5 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.js +27 -3
- package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/lib/theme/ApiExplorer/Request/index.js +9 -3
- package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/lib/theme/ApiExplorer/Response/index.js +2 -1
- package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/Server/index.js +6 -3
- package/lib/theme/styles.scss +1 -0
- package/package.json +4 -3
- package/src/index.ts +2 -0
- package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +44 -26
- package/src/theme/ApiExplorer/Body/index.tsx +7 -8
- package/src/theme/ApiExplorer/ContentType/index.tsx +2 -1
- package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/src/theme/ApiExplorer/FormItem/index.tsx +2 -16
- package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
- package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
- package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
- package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +65 -9
- package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/src/theme/ApiExplorer/Request/index.tsx +11 -6
- package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/src/theme/ApiExplorer/Response/index.tsx +3 -2
- package/src/theme/ApiExplorer/Server/index.tsx +10 -3
- package/src/theme/styles.scss +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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(
|
package/lib/theme/styles.scss
CHANGED
|
@@ -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-
|
|
4
|
+
"version": "0.0.0-1130",
|
|
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-
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1130",
|
|
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": "
|
|
85
|
+
"gitHead": "5e9591e0e848677c7589a091580feffcc0a86b41"
|
|
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: [
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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)
|
|
@@ -318,18 +318,17 @@ function Body({
|
|
|
318
318
|
<FormItem className="openapi-explorer__form-item-body-container">
|
|
319
319
|
{Object.entries(schema.properties ?? {}).map(([key, val]: any) => {
|
|
320
320
|
return (
|
|
321
|
-
<FormItem
|
|
322
|
-
key={key}
|
|
323
|
-
label={key}
|
|
324
|
-
required={
|
|
325
|
-
Array.isArray(schema.required) && schema.required.includes(key)
|
|
326
|
-
}
|
|
327
|
-
>
|
|
321
|
+
<FormItem key={key}>
|
|
328
322
|
<FormBodyItem
|
|
329
323
|
schemaObject={val}
|
|
330
324
|
id={key}
|
|
331
325
|
schema={schema}
|
|
332
|
-
|
|
326
|
+
label={key}
|
|
327
|
+
required={
|
|
328
|
+
Array.isArray(schema.required) &&
|
|
329
|
+
schema.required.includes(key)
|
|
330
|
+
}
|
|
331
|
+
/>
|
|
333
332
|
</FormItem>
|
|
334
333
|
);
|
|
335
334
|
})}
|
|
@@ -7,31 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
-
import { translate } from "@docusaurus/Translate";
|
|
11
|
-
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
12
10
|
import clsx from "clsx";
|
|
13
11
|
|
|
14
12
|
export interface Props {
|
|
15
|
-
label?: string;
|
|
16
|
-
type?: string;
|
|
17
|
-
required?: boolean | undefined;
|
|
18
13
|
children?: React.ReactNode;
|
|
19
14
|
className?: string;
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
function FormItem({
|
|
17
|
+
function FormItem({ children, className }: Props) {
|
|
23
18
|
return (
|
|
24
19
|
<div className={clsx("openapi-explorer__form-item", className)}>
|
|
25
|
-
{
|
|
26
|
-
<label className="openapi-explorer__form-item-label">{label}</label>
|
|
27
|
-
)}
|
|
28
|
-
{type && <span style={{ opacity: 0.6 }}> — {type}</span>}
|
|
29
|
-
{required && (
|
|
30
|
-
<span className="openapi-schema__required">
|
|
31
|
-
{translate({ id: OPENAPI_SCHEMA_ITEM.REQUIRED, message: "required" })}
|
|
32
|
-
</span>
|
|
33
|
-
)}
|
|
34
|
-
<div>{children}</div>
|
|
20
|
+
{children}
|
|
35
21
|
</div>
|
|
36
22
|
);
|
|
37
23
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 React from "react";
|
|
9
|
+
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
|
+
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
12
|
+
|
|
13
|
+
export interface Props {
|
|
14
|
+
htmlFor?: string;
|
|
15
|
+
label: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function FormLabel({ htmlFor, label, type, required }: Props) {
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
{htmlFor ? (
|
|
24
|
+
<label className="openapi-explorer__form-item-label" htmlFor={htmlFor}>
|
|
25
|
+
{label}
|
|
26
|
+
</label>
|
|
27
|
+
) : (
|
|
28
|
+
<span className="openapi-explorer__form-item-label">{label}</span>
|
|
29
|
+
)}
|
|
30
|
+
{type && <span style={{ opacity: 0.6 }}> — {type}</span>}
|
|
31
|
+
{required && (
|
|
32
|
+
<span className="openapi-schema__required">
|
|
33
|
+
{translate({
|
|
34
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
35
|
+
message: "required",
|
|
36
|
+
})}
|
|
37
|
+
</span>
|
|
38
|
+
)}
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default FormLabel;
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import React, { useId } from "react";
|
|
9
9
|
|
|
10
|
+
import FormLabel from "@theme/ApiExplorer/FormLabel";
|
|
10
11
|
import clsx from "clsx";
|
|
11
12
|
|
|
12
13
|
export interface Props {
|
|
@@ -14,9 +15,22 @@ export interface Props {
|
|
|
14
15
|
options: string[];
|
|
15
16
|
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
16
17
|
showErrors?: boolean;
|
|
18
|
+
label?: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
required?: boolean;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
function FormMultiSelect({
|
|
23
|
+
function FormMultiSelect({
|
|
24
|
+
value,
|
|
25
|
+
options,
|
|
26
|
+
onChange,
|
|
27
|
+
showErrors,
|
|
28
|
+
label,
|
|
29
|
+
type,
|
|
30
|
+
required,
|
|
31
|
+
}: Props) {
|
|
32
|
+
const id = useId();
|
|
33
|
+
|
|
20
34
|
if (options.length === 0) {
|
|
21
35
|
return null;
|
|
22
36
|
}
|
|
@@ -33,24 +47,30 @@ function FormMultiSelect({ value, options, onChange, showErrors }: Props) {
|
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
return (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
<>
|
|
51
|
+
{label && (
|
|
52
|
+
<FormLabel htmlFor={id} label={label} type={type} required={required} />
|
|
53
|
+
)}
|
|
54
|
+
<select
|
|
55
|
+
id={label ? id : undefined}
|
|
56
|
+
style={{ height: height }}
|
|
57
|
+
className={clsx("openapi-explorer__multi-select-input", {
|
|
58
|
+
error: showErrors,
|
|
59
|
+
})}
|
|
60
|
+
value={value}
|
|
61
|
+
onChange={onChange}
|
|
62
|
+
size={Math.min(6, options.length + 1)}
|
|
63
|
+
multiple
|
|
64
|
+
>
|
|
65
|
+
{options.map((option) => {
|
|
66
|
+
return (
|
|
67
|
+
<option key={option} value={option}>
|
|
68
|
+
{option}
|
|
69
|
+
</option>
|
|
70
|
+
);
|
|
71
|
+
})}
|
|
72
|
+
</select>
|
|
73
|
+
</>
|
|
54
74
|
);
|
|
55
75
|
}
|
|
56
76
|
|
|
@@ -5,33 +5,59 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import React, { useId } from "react";
|
|
9
|
+
|
|
10
|
+
import FormLabel from "@theme/ApiExplorer/FormLabel";
|
|
9
11
|
|
|
10
12
|
export interface Props {
|
|
11
13
|
value?: string;
|
|
12
14
|
options?: string[];
|
|
13
15
|
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
16
|
+
label?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
ariaLabelledBy?: string;
|
|
20
|
+
ariaLabel?: string;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
function FormSelect({
|
|
23
|
+
function FormSelect({
|
|
24
|
+
value,
|
|
25
|
+
options,
|
|
26
|
+
onChange,
|
|
27
|
+
label,
|
|
28
|
+
type,
|
|
29
|
+
required,
|
|
30
|
+
ariaLabelledBy,
|
|
31
|
+
ariaLabel,
|
|
32
|
+
}: Props) {
|
|
33
|
+
const id = useId();
|
|
34
|
+
|
|
17
35
|
if (!Array.isArray(options) || options.length === 0) {
|
|
18
36
|
return null;
|
|
19
37
|
}
|
|
20
38
|
|
|
21
39
|
return (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
<>
|
|
41
|
+
{label && (
|
|
42
|
+
<FormLabel htmlFor={id} label={label} type={type} required={required} />
|
|
43
|
+
)}
|
|
44
|
+
<select
|
|
45
|
+
id={label ? id : undefined}
|
|
46
|
+
className="openapi-explorer__select-input"
|
|
47
|
+
value={value}
|
|
48
|
+
onChange={onChange}
|
|
49
|
+
aria-labelledby={!label ? ariaLabelledBy : undefined}
|
|
50
|
+
aria-label={!label && !ariaLabelledBy ? ariaLabel : undefined}
|
|
51
|
+
>
|
|
52
|
+
{options.map((option) => {
|
|
53
|
+
return (
|
|
54
|
+
<option key={option} value={option}>
|
|
55
|
+
{option}
|
|
56
|
+
</option>
|
|
57
|
+
);
|
|
58
|
+
})}
|
|
59
|
+
</select>
|
|
60
|
+
</>
|
|
35
61
|
);
|
|
36
62
|
}
|
|
37
63
|
|