docusaurus-theme-openapi-docs 1.4.2 → 1.4.4
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 +5 -8
- package/lib/markdown/createDescription.js +1 -2
- package/lib/markdown/schema.js +7 -42
- package/lib/markdown/utils.js +1 -7
- package/lib/theme/ApiDemoPanel/Accept/index.js +1 -10
- package/lib/theme/ApiDemoPanel/Accept/slice.js +1 -2
- package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +7 -8
- package/lib/theme/ApiDemoPanel/Authorization/index.js +1 -19
- package/lib/theme/ApiDemoPanel/Authorization/slice.js +7 -21
- package/lib/theme/ApiDemoPanel/Body/index.js +14 -47
- package/lib/theme/ApiDemoPanel/Body/slice.js +1 -4
- package/lib/theme/ApiDemoPanel/CodeTabs/index.js +14 -46
- package/lib/theme/ApiDemoPanel/ContentType/index.js +1 -10
- package/lib/theme/ApiDemoPanel/ContentType/slice.js +1 -2
- package/lib/theme/ApiDemoPanel/Curl/index.js +9 -29
- package/lib/theme/ApiDemoPanel/Execute/index.js +6 -23
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +4 -27
- package/lib/theme/ApiDemoPanel/Export/index.js +1 -8
- package/lib/theme/ApiDemoPanel/FloatingButton/index.js +1 -5
- package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +1 -14
- package/lib/theme/ApiDemoPanel/FormItem/index.js +1 -5
- package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +1 -8
- package/lib/theme/ApiDemoPanel/FormSelect/index.js +1 -6
- package/lib/theme/ApiDemoPanel/FormTextInput/index.js +1 -6
- package/lib/theme/ApiDemoPanel/LiveEditor/index.js +3 -17
- package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +1 -12
- package/lib/theme/ApiDemoPanel/ParamOptions/index.js +20 -52
- package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +1 -2
- package/lib/theme/ApiDemoPanel/Request/index.js +1 -15
- package/lib/theme/ApiDemoPanel/Response/index.js +1 -14
- package/lib/theme/ApiDemoPanel/Response/slice.js +1 -2
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +1 -9
- package/lib/theme/ApiDemoPanel/Server/index.js +3 -27
- package/lib/theme/ApiDemoPanel/Server/slice.js +1 -3
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +11 -62
- package/lib/theme/ApiDemoPanel/index.js +2 -14
- package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +5 -11
- package/lib/theme/ApiDemoPanel/storage-utils.js +1 -7
- package/lib/theme/ApiItem/Layout/index.js +5 -22
- package/lib/theme/ApiItem/Layout/styles.module.css +0 -403
- package/lib/theme/ApiItem/hooks.js +1 -3
- package/lib/theme/ApiItem/index.js +14 -30
- package/lib/theme/ApiItem/store.js +1 -14
- package/lib/theme/ApiLogo/index.js +1 -4
- package/lib/theme/styles.css +428 -0
- package/lib/theme-classic.d.ts +5 -0
- package/lib-next/index.js +5 -3
- package/lib-next/markdown/createDescription.js +1 -1
- package/lib-next/markdown/schema.js +7 -35
- package/lib-next/markdown/utils.js +1 -4
- package/lib-next/theme/ApiDemoPanel/Accept/index.js +1 -4
- package/lib-next/theme/ApiDemoPanel/Accept/slice.js +1 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +7 -4
- package/lib-next/theme/ApiDemoPanel/Authorization/index.js +1 -8
- package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +12 -14
- package/lib-next/theme/ApiDemoPanel/Body/index.js +16 -34
- package/lib-next/theme/ApiDemoPanel/Body/slice.js +1 -2
- package/lib-next/theme/ApiDemoPanel/CodeTabs/index.js +12 -26
- package/lib-next/theme/ApiDemoPanel/ContentType/index.js +1 -4
- package/lib-next/theme/ApiDemoPanel/ContentType/slice.js +1 -0
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +11 -12
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +10 -13
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +4 -22
- package/lib-next/theme/ApiDemoPanel/Export/index.js +1 -5
- package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +1 -2
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +1 -7
- package/lib-next/theme/ApiDemoPanel/FormItem/index.js +1 -2
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +1 -5
- package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +1 -3
- package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +1 -2
- package/lib-next/theme/ApiDemoPanel/LiveEditor/index.js +3 -6
- package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +1 -9
- package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +34 -29
- package/lib-next/theme/ApiDemoPanel/ParamOptions/slice.js +1 -0
- package/lib-next/theme/ApiDemoPanel/Request/index.js +1 -2
- package/lib-next/theme/ApiDemoPanel/Response/index.js +3 -9
- package/lib-next/theme/ApiDemoPanel/Response/slice.js +1 -0
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +1 -5
- package/lib-next/theme/ApiDemoPanel/Server/index.js +3 -13
- package/lib-next/theme/ApiDemoPanel/Server/slice.js +1 -0
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +12 -49
- package/lib-next/theme/ApiDemoPanel/index.js +2 -4
- package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +5 -6
- package/lib-next/theme/ApiDemoPanel/storage-utils.js +1 -3
- package/lib-next/theme/ApiItem/Layout/index.js +8 -9
- package/lib-next/theme/ApiItem/Layout/styles.module.css +0 -403
- package/lib-next/theme/ApiItem/hooks.js +1 -0
- package/lib-next/theme/ApiItem/index.js +14 -13
- package/lib-next/theme/ApiItem/store.js +1 -0
- package/lib-next/theme/ApiLogo/index.js +1 -0
- package/lib-next/theme/styles.css +428 -0
- package/lib-next/theme-classic.d.ts +5 -0
- package/package.json +5 -5
- package/src/index.ts +5 -0
- package/src/theme/ApiDemoPanel/Execute/index.tsx +1 -0
- package/src/theme/ApiDemoPanel/index.tsx +1 -2
- package/src/theme/ApiItem/Layout/index.tsx +5 -6
- package/src/theme/ApiItem/Layout/styles.module.css +0 -403
- package/src/theme/ApiItem/index.tsx +5 -4
- package/src/theme/styles.css +428 -0
- package/src/theme-classic.d.ts +5 -0
- package/lib/theme/ApiDemoPanel/styles.module.css +0 -44
- package/lib/theme/ApiItem/Content/index.js +0 -65
- package/lib/theme/ApiItem/Footer/index.js +0 -78
- package/lib/theme/ApiItem/Footer/styles.module.css +0 -18
- package/lib/theme/ApiItem/Metadata/index.js +0 -32
- package/lib/theme/ApiItem/Paginator/index.js +0 -33
- package/lib/theme/ApiItem/TOC/Desktop/index.js +0 -31
- package/lib/theme/ApiItem/TOC/Mobile/index.js +0 -35
- package/lib/theme/ApiItem/TOC/Mobile/styles.module.css +0 -19
- package/lib-next/theme/ApiDemoPanel/styles.module.css +0 -44
- package/lib-next/theme/ApiItem/Content/index.js +0 -55
- package/lib-next/theme/ApiItem/Footer/index.js +0 -88
- package/lib-next/theme/ApiItem/Footer/styles.module.css +0 -18
- package/lib-next/theme/ApiItem/Metadata/index.js +0 -21
- package/lib-next/theme/ApiItem/Paginator/index.js +0 -19
- package/lib-next/theme/ApiItem/TOC/Desktop/index.js +0 -22
- package/lib-next/theme/ApiItem/TOC/Mobile/index.js +0 -24
- package/lib-next/theme/ApiItem/TOC/Mobile/styles.module.css +0 -19
- package/src/theme/ApiDemoPanel/styles.module.css +0 -44
- package/src/theme/ApiItem/Content/index.tsx +0 -57
- package/src/theme/ApiItem/Footer/index.tsx +0 -101
- package/src/theme/ApiItem/Footer/styles.module.css +0 -18
- package/src/theme/ApiItem/Metadata/index.tsx +0 -24
- package/src/theme/ApiItem/Paginator/index.tsx +0 -21
- package/src/theme/ApiItem/TOC/Desktop/index.tsx +0 -25
- package/src/theme/ApiItem/TOC/Mobile/index.tsx +0 -28
- package/src/theme/ApiItem/TOC/Mobile/styles.module.css +0 -19
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import React, { useState, useEffect } from "react";
|
|
8
9
|
import { nanoid } from "@reduxjs/toolkit";
|
|
9
10
|
import { useTypedDispatch, useTypedSelector } from "../../ApiItem/hooks";
|
|
@@ -13,28 +14,24 @@ import FormSelect from "./../FormSelect";
|
|
|
13
14
|
import FormTextInput from "./../FormTextInput";
|
|
14
15
|
import { setParam } from "./slice";
|
|
15
16
|
import styles from "./styles.module.css";
|
|
16
|
-
|
|
17
17
|
function ParamOption({ param }) {
|
|
18
18
|
if (param.schema?.type === "array" && param.schema.items?.enum) {
|
|
19
19
|
return <ParamMultiSelectFormItem param={param} />;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
21
|
if (param.schema?.type === "array") {
|
|
23
22
|
return <ParamArrayFormItem param={param} />;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
if (param.schema?.enum) {
|
|
27
25
|
return <ParamSelectFormItem param={param} />;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
27
|
if (param.schema?.type === "boolean") {
|
|
31
28
|
return <ParamBooleanFormItem param={param} />;
|
|
32
|
-
}
|
|
33
|
-
// date-time, date, password
|
|
29
|
+
}
|
|
34
30
|
|
|
31
|
+
// integer, number, string, int32, int64, float, double, object, byte, binary,
|
|
32
|
+
// date-time, date, password
|
|
35
33
|
return <ParamTextFormItem param={param} />;
|
|
36
34
|
}
|
|
37
|
-
|
|
38
35
|
function ParamOptionWrapper({ param }) {
|
|
39
36
|
return (
|
|
40
37
|
<FormItem label={param.name} type={param.in} required={param.required}>
|
|
@@ -42,7 +39,6 @@ function ParamOptionWrapper({ param }) {
|
|
|
42
39
|
</FormItem>
|
|
43
40
|
);
|
|
44
41
|
}
|
|
45
|
-
|
|
46
42
|
function ParamOptions() {
|
|
47
43
|
const [showOptional, setShowOptional] = useState(false);
|
|
48
44
|
const pathParams = useTypedSelector((state) => state.params.path);
|
|
@@ -121,7 +117,6 @@ function ParamOptions() {
|
|
|
121
117
|
</>
|
|
122
118
|
);
|
|
123
119
|
}
|
|
124
|
-
|
|
125
120
|
function ArrayItem({ param, onChange }) {
|
|
126
121
|
if (param.schema?.items?.type === "boolean") {
|
|
127
122
|
return (
|
|
@@ -134,7 +129,6 @@ function ArrayItem({ param, onChange }) {
|
|
|
134
129
|
/>
|
|
135
130
|
);
|
|
136
131
|
}
|
|
137
|
-
|
|
138
132
|
return (
|
|
139
133
|
<FormTextInput
|
|
140
134
|
placeholder={param.description || param.name}
|
|
@@ -144,11 +138,9 @@ function ArrayItem({ param, onChange }) {
|
|
|
144
138
|
/>
|
|
145
139
|
);
|
|
146
140
|
}
|
|
147
|
-
|
|
148
141
|
function ParamArrayFormItem({ param }) {
|
|
149
142
|
const [items, setItems] = useState([]);
|
|
150
143
|
const dispatch = useTypedDispatch();
|
|
151
|
-
|
|
152
144
|
function handleAddItem() {
|
|
153
145
|
setItems((i) => [
|
|
154
146
|
...i,
|
|
@@ -157,34 +149,36 @@ function ParamArrayFormItem({ param }) {
|
|
|
157
149
|
},
|
|
158
150
|
]);
|
|
159
151
|
}
|
|
160
|
-
|
|
161
152
|
useEffect(() => {
|
|
162
153
|
const values = items.map((item) => item.value).filter((item) => !!item);
|
|
163
154
|
dispatch(
|
|
164
|
-
setParam({
|
|
165
|
-
|
|
155
|
+
setParam({
|
|
156
|
+
...param,
|
|
157
|
+
value: values.length > 0 ? values : undefined,
|
|
158
|
+
})
|
|
159
|
+
);
|
|
160
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
161
|
}, [items]);
|
|
167
|
-
|
|
168
162
|
function handleDeleteItem(itemToDelete) {
|
|
169
163
|
return () => {
|
|
170
164
|
const newItems = items.filter((i) => i.id !== itemToDelete.id);
|
|
171
165
|
setItems(newItems);
|
|
172
166
|
};
|
|
173
167
|
}
|
|
174
|
-
|
|
175
168
|
function handleChangeItem(itemToUpdate) {
|
|
176
169
|
return (value) => {
|
|
177
170
|
const newItems = items.map((i) => {
|
|
178
171
|
if (i.id === itemToUpdate.id) {
|
|
179
|
-
return {
|
|
172
|
+
return {
|
|
173
|
+
...i,
|
|
174
|
+
value: value,
|
|
175
|
+
};
|
|
180
176
|
}
|
|
181
|
-
|
|
182
177
|
return i;
|
|
183
178
|
});
|
|
184
179
|
setItems(newItems);
|
|
185
180
|
};
|
|
186
181
|
}
|
|
187
|
-
|
|
188
182
|
return (
|
|
189
183
|
<>
|
|
190
184
|
{items.map((item) => (
|
|
@@ -221,7 +215,6 @@ function ParamArrayFormItem({ param }) {
|
|
|
221
215
|
</>
|
|
222
216
|
);
|
|
223
217
|
}
|
|
224
|
-
|
|
225
218
|
function ParamSelectFormItem({ param }) {
|
|
226
219
|
const dispatch = useTypedDispatch();
|
|
227
220
|
const options = param.schema?.enum ?? [];
|
|
@@ -231,13 +224,15 @@ function ParamSelectFormItem({ param }) {
|
|
|
231
224
|
onChange={(e) => {
|
|
232
225
|
const val = e.target.value;
|
|
233
226
|
dispatch(
|
|
234
|
-
setParam({
|
|
227
|
+
setParam({
|
|
228
|
+
...param,
|
|
229
|
+
value: val === "---" ? undefined : val,
|
|
230
|
+
})
|
|
235
231
|
);
|
|
236
232
|
}}
|
|
237
233
|
/>
|
|
238
234
|
);
|
|
239
235
|
}
|
|
240
|
-
|
|
241
236
|
function ParamBooleanFormItem({ param }) {
|
|
242
237
|
const dispatch = useTypedDispatch();
|
|
243
238
|
return (
|
|
@@ -246,13 +241,15 @@ function ParamBooleanFormItem({ param }) {
|
|
|
246
241
|
onChange={(e) => {
|
|
247
242
|
const val = e.target.value;
|
|
248
243
|
dispatch(
|
|
249
|
-
setParam({
|
|
244
|
+
setParam({
|
|
245
|
+
...param,
|
|
246
|
+
value: val === "---" ? undefined : val,
|
|
247
|
+
})
|
|
250
248
|
);
|
|
251
249
|
}}
|
|
252
250
|
/>
|
|
253
251
|
);
|
|
254
252
|
}
|
|
255
|
-
|
|
256
253
|
function ParamMultiSelectFormItem({ param }) {
|
|
257
254
|
const dispatch = useTypedDispatch();
|
|
258
255
|
const options = param.schema?.items?.enum ?? [];
|
|
@@ -264,21 +261,29 @@ function ParamMultiSelectFormItem({ param }) {
|
|
|
264
261
|
.call(e.target.options, (o) => o.selected)
|
|
265
262
|
.map((o) => o.value);
|
|
266
263
|
dispatch(
|
|
267
|
-
setParam({
|
|
264
|
+
setParam({
|
|
265
|
+
...param,
|
|
266
|
+
value: values.length > 0 ? values : undefined,
|
|
267
|
+
})
|
|
268
268
|
);
|
|
269
269
|
}}
|
|
270
270
|
/>
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
|
-
|
|
274
273
|
function ParamTextFormItem({ param }) {
|
|
275
274
|
const dispatch = useTypedDispatch();
|
|
276
275
|
return (
|
|
277
276
|
<FormTextInput
|
|
278
277
|
placeholder={param.description || param.name}
|
|
279
|
-
onChange={(e) =>
|
|
278
|
+
onChange={(e) =>
|
|
279
|
+
dispatch(
|
|
280
|
+
setParam({
|
|
281
|
+
...param,
|
|
282
|
+
value: e.target.value,
|
|
283
|
+
})
|
|
284
|
+
)
|
|
285
|
+
}
|
|
280
286
|
/>
|
|
281
287
|
);
|
|
282
288
|
}
|
|
283
|
-
|
|
284
289
|
export default ParamOptions;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import { createSlice } from "@reduxjs/toolkit";
|
|
8
9
|
const initialState = {};
|
|
9
10
|
export const slice = createSlice({
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import React from "react";
|
|
8
9
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
9
10
|
import sdk from "@paloaltonetworks/postman-collection";
|
|
@@ -15,7 +16,6 @@ import Execute from "../Execute";
|
|
|
15
16
|
import ParamOptions from "../ParamOptions";
|
|
16
17
|
import Server from "../Server";
|
|
17
18
|
import styles from "./styles.module.css";
|
|
18
|
-
|
|
19
19
|
function Request({ item }) {
|
|
20
20
|
const response = useTypedSelector((state) => state.response.value);
|
|
21
21
|
const { siteConfig } = useDocusaurusContext();
|
|
@@ -58,5 +58,4 @@ function Request({ item }) {
|
|
|
58
58
|
</div>
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
|
-
|
|
62
61
|
export default Request;
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import React from "react";
|
|
8
9
|
import CodeBlock from "@theme/CodeBlock";
|
|
9
10
|
import { useTypedDispatch, useTypedSelector } from "../../ApiItem/hooks";
|
|
10
|
-
import { clearResponse } from "./slice";
|
|
11
|
+
import { clearResponse } from "./slice";
|
|
11
12
|
|
|
13
|
+
// TODO: We probably shouldn't attempt to format XML...
|
|
12
14
|
function formatXml(xml) {
|
|
13
15
|
const tab = " ";
|
|
14
16
|
let formatted = "";
|
|
@@ -18,9 +20,7 @@ function formatXml(xml) {
|
|
|
18
20
|
// decrease indent by one 'tab'
|
|
19
21
|
indent = indent.substring(tab.length);
|
|
20
22
|
}
|
|
21
|
-
|
|
22
23
|
formatted += indent + "<" + node + ">\r\n";
|
|
23
|
-
|
|
24
24
|
if (node.match(/^<?\w[^>]*[^/]$/)) {
|
|
25
25
|
// increase indent
|
|
26
26
|
indent += tab;
|
|
@@ -28,17 +28,13 @@ function formatXml(xml) {
|
|
|
28
28
|
});
|
|
29
29
|
return formatted.substring(1, formatted.length - 3);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
31
|
function Response() {
|
|
33
32
|
const response = useTypedSelector((state) => state.response.value);
|
|
34
33
|
const dispatch = useTypedDispatch();
|
|
35
|
-
|
|
36
34
|
if (response === undefined) {
|
|
37
35
|
return null;
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
let prettyResponse = response;
|
|
41
|
-
|
|
42
38
|
try {
|
|
43
39
|
prettyResponse = JSON.stringify(JSON.parse(response), null, 2);
|
|
44
40
|
} catch {
|
|
@@ -46,7 +42,6 @@ function Response() {
|
|
|
46
42
|
prettyResponse = formatXml(response);
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
|
-
|
|
50
45
|
return (
|
|
51
46
|
<details className={`details__demo-panel`} open={true}>
|
|
52
47
|
<summary>
|
|
@@ -66,5 +61,4 @@ function Response() {
|
|
|
66
61
|
</details>
|
|
67
62
|
);
|
|
68
63
|
}
|
|
69
|
-
|
|
70
64
|
export default Response;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import { createSlice } from "@reduxjs/toolkit";
|
|
8
9
|
const initialState = {};
|
|
9
10
|
export const slice = createSlice({
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import React from "react";
|
|
8
9
|
import Link from "@docusaurus/Link";
|
|
9
10
|
import { useTypedSelector } from "../../ApiItem/hooks";
|
|
10
|
-
|
|
11
11
|
function SecuritySchemes(props) {
|
|
12
12
|
const options = useTypedSelector((state) => state.auth.options);
|
|
13
13
|
const selected = useTypedSelector((state) => state.auth.selected);
|
|
@@ -23,7 +23,6 @@ function SecuritySchemes(props) {
|
|
|
23
23
|
const isApiKey = auth.type === "apiKey";
|
|
24
24
|
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
25
25
|
const isOauth2 = auth.type === "oauth2";
|
|
26
|
-
|
|
27
26
|
if (isApiKey || isBearer) {
|
|
28
27
|
return (
|
|
29
28
|
<React.Fragment key={auth.key}>
|
|
@@ -43,7 +42,6 @@ function SecuritySchemes(props) {
|
|
|
43
42
|
</React.Fragment>
|
|
44
43
|
);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
45
|
if (isOauth2) {
|
|
48
46
|
return (
|
|
49
47
|
<React.Fragment key={selected}>
|
|
@@ -67,11 +65,9 @@ function SecuritySchemes(props) {
|
|
|
67
65
|
</React.Fragment>
|
|
68
66
|
);
|
|
69
67
|
}
|
|
70
|
-
|
|
71
68
|
return undefined;
|
|
72
69
|
})}
|
|
73
70
|
</details>
|
|
74
71
|
);
|
|
75
72
|
}
|
|
76
|
-
|
|
77
73
|
export default SecuritySchemes;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import React, { useState } from "react";
|
|
8
9
|
import { useTypedDispatch, useTypedSelector } from "../../ApiItem/hooks";
|
|
9
10
|
import FloatingButton from "../FloatingButton";
|
|
@@ -12,41 +13,34 @@ import FormSelect from "./../FormSelect";
|
|
|
12
13
|
import FormTextInput from "./../FormTextInput";
|
|
13
14
|
import { setServer, setServerVariable } from "./slice";
|
|
14
15
|
import styles from "./styles.module.css";
|
|
15
|
-
|
|
16
16
|
function Server() {
|
|
17
17
|
const [isEditing, setIsEditing] = useState(false);
|
|
18
18
|
const value = useTypedSelector((state) => state.server.value);
|
|
19
19
|
const options = useTypedSelector((state) => state.server.options);
|
|
20
20
|
const dispatch = useTypedDispatch();
|
|
21
|
-
|
|
22
21
|
if (options.length <= 0) {
|
|
23
22
|
return null;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
if (options.length < 1 && value?.variables === undefined) {
|
|
27
25
|
return null;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
27
|
if (!value) {
|
|
31
28
|
const defaultOption = options[0];
|
|
32
29
|
dispatch(setServer(JSON.stringify(defaultOption)));
|
|
33
|
-
}
|
|
30
|
+
}
|
|
34
31
|
|
|
32
|
+
// Default to first option when existing server state is mismatched
|
|
35
33
|
if (value) {
|
|
36
34
|
const urlExists = options.find((s) => s.url === value.url);
|
|
37
|
-
|
|
38
35
|
if (!urlExists) {
|
|
39
36
|
const defaultOption = options[0];
|
|
40
37
|
dispatch(setServer(JSON.stringify(defaultOption)));
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
if (!isEditing) {
|
|
45
41
|
let url = "";
|
|
46
|
-
|
|
47
42
|
if (value) {
|
|
48
43
|
url = value.url.replace(/\/$/, "");
|
|
49
|
-
|
|
50
44
|
if (value.variables) {
|
|
51
45
|
Object.keys(value.variables).forEach((variable) => {
|
|
52
46
|
url = url.replace(
|
|
@@ -56,7 +50,6 @@ function Server() {
|
|
|
56
50
|
});
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
|
-
|
|
60
53
|
return (
|
|
61
54
|
<FloatingButton onClick={() => setIsEditing(true)} label="Edit">
|
|
62
55
|
<FormItem label="Base URL">
|
|
@@ -72,7 +65,6 @@ function Server() {
|
|
|
72
65
|
</FloatingButton>
|
|
73
66
|
);
|
|
74
67
|
}
|
|
75
|
-
|
|
76
68
|
return (
|
|
77
69
|
<div className={styles.optionsPanel}>
|
|
78
70
|
<FloatingButton onClick={() => setIsEditing(false)} label="Hide">
|
|
@@ -114,7 +106,6 @@ function Server() {
|
|
|
114
106
|
</FormItem>
|
|
115
107
|
);
|
|
116
108
|
}
|
|
117
|
-
|
|
118
109
|
return (
|
|
119
110
|
<FormItem label={key}>
|
|
120
111
|
<FormTextInput
|
|
@@ -138,5 +129,4 @@ function Server() {
|
|
|
138
129
|
</div>
|
|
139
130
|
);
|
|
140
131
|
}
|
|
141
|
-
|
|
142
132
|
export default Server;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
|
+
|
|
7
8
|
import { createSlice } from "@reduxjs/toolkit";
|
|
8
9
|
const initialState = {};
|
|
9
10
|
export const slice = createSlice({
|