docusaurus-theme-openapi-docs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/babel.config.js +35 -0
- package/lib/index.js +48 -0
- package/lib/markdown/createDescription.js +20 -0
- package/lib/markdown/schema.js +121 -0
- package/lib/markdown/utils.js +45 -0
- package/lib/theme/ApiDemoPanel/Accept/index.js +41 -0
- package/lib/theme/ApiDemoPanel/Accept/slice.js +32 -0
- package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +32 -0
- package/lib/theme/ApiDemoPanel/Authorization/index.js +174 -0
- package/lib/theme/ApiDemoPanel/Authorization/slice.js +137 -0
- package/lib/theme/ApiDemoPanel/Body/index.js +185 -0
- package/lib/theme/ApiDemoPanel/Body/slice.js +105 -0
- package/lib/theme/ApiDemoPanel/ContentType/index.js +41 -0
- package/lib/theme/ApiDemoPanel/ContentType/slice.js +32 -0
- package/lib/theme/ApiDemoPanel/Curl/index.js +236 -0
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib/theme/ApiDemoPanel/Execute/index.js +85 -0
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +202 -0
- package/lib/theme/ApiDemoPanel/FloatingButton/index.js +32 -0
- package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +97 -0
- package/lib/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/lib/theme/ApiDemoPanel/FormItem/index.js +35 -0
- package/lib/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +52 -0
- package/lib/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/lib/theme/ApiDemoPanel/FormSelect/index.js +39 -0
- package/lib/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/lib/theme/ApiDemoPanel/FormTextInput/index.js +30 -0
- package/lib/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +60 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/index.js +248 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +35 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/lib/theme/ApiDemoPanel/Response/index.js +75 -0
- package/lib/theme/ApiDemoPanel/Response/slice.js +37 -0
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +51 -0
- package/lib/theme/ApiDemoPanel/Server/index.js +109 -0
- package/lib/theme/ApiDemoPanel/Server/slice.js +41 -0
- package/lib/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/lib/theme/ApiDemoPanel/VSCode/index.js +252 -0
- package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +329 -0
- package/lib/theme/ApiDemoPanel/hooks.js +20 -0
- package/lib/theme/ApiDemoPanel/index.js +134 -0
- package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +44 -0
- package/lib/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/lib/theme/ApiDemoPanel/storage-utils.js +47 -0
- package/lib/theme/ApiDemoPanel/store.js +48 -0
- package/lib/theme/ApiDemoPanel/styles.module.css +44 -0
- package/lib/theme/ApiItem/index.js +160 -0
- package/lib/theme/ApiItem/styles.module.css +109 -0
- package/lib/theme/ParamsItem/index.js +68 -0
- package/lib/theme/ParamsItem/styles.module.css +24 -0
- package/lib/theme/SchemaItem/index.js +58 -0
- package/lib/theme/SchemaItem/styles.module.css +24 -0
- package/lib/theme/Tabs/index.js +258 -0
- package/lib/theme/Tabs/styles.module.css +118 -0
- package/lib/theme-classic.d.ts +8 -0
- package/lib/theme-openapi.d.ts +48 -0
- package/lib/theme-translations.d.ts +9 -0
- package/lib/types.js +1 -0
- package/lib-next/index.js +38 -0
- package/lib-next/markdown/createDescription.js +13 -0
- package/lib-next/markdown/schema.js +115 -0
- package/lib-next/markdown/utils.js +31 -0
- package/lib-next/theme/ApiDemoPanel/Accept/index.js +33 -0
- package/lib-next/theme/ApiDemoPanel/Accept/slice.js +19 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +22 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/index.js +203 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +101 -0
- package/lib-next/theme/ApiDemoPanel/Body/index.js +210 -0
- package/lib-next/theme/ApiDemoPanel/Body/slice.js +89 -0
- package/lib-next/theme/ApiDemoPanel/ContentType/index.js +33 -0
- package/lib-next/theme/ApiDemoPanel/ContentType/slice.js +19 -0
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +264 -0
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +74 -0
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +183 -0
- package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +19 -0
- package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +113 -0
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/lib-next/theme/ApiDemoPanel/FormItem/index.js +29 -0
- package/lib-next/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +49 -0
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +28 -0
- package/lib-next/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +23 -0
- package/lib-next/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +53 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +284 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/slice.js +22 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/lib-next/theme/ApiDemoPanel/Response/index.js +65 -0
- package/lib-next/theme/ApiDemoPanel/Response/slice.js +22 -0
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +48 -0
- package/lib-next/theme/ApiDemoPanel/Server/index.js +114 -0
- package/lib-next/theme/ApiDemoPanel/Server/slice.js +25 -0
- package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/lib-next/theme/ApiDemoPanel/VSCode/index.js +265 -0
- package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +310 -0
- package/lib-next/theme/ApiDemoPanel/hooks.js +9 -0
- package/lib-next/theme/ApiDemoPanel/index.js +110 -0
- package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +38 -0
- package/lib-next/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/lib-next/theme/ApiDemoPanel/storage-utils.js +35 -0
- package/lib-next/theme/ApiDemoPanel/store.js +30 -0
- package/lib-next/theme/ApiDemoPanel/styles.module.css +44 -0
- package/lib-next/theme/ApiItem/index.js +171 -0
- package/lib-next/theme/ApiItem/styles.module.css +109 -0
- package/lib-next/theme/ParamsItem/index.js +68 -0
- package/lib-next/theme/ParamsItem/styles.module.css +24 -0
- package/lib-next/theme/SchemaItem/index.js +58 -0
- package/lib-next/theme/SchemaItem/styles.module.css +24 -0
- package/lib-next/theme/Tabs/index.js +258 -0
- package/lib-next/theme/Tabs/styles.module.css +118 -0
- package/lib-next/theme-classic.d.ts +8 -0
- package/lib-next/theme-openapi.d.ts +48 -0
- package/lib-next/theme-translations.d.ts +9 -0
- package/lib-next/types.js +1 -0
- package/package.json +68 -0
- package/src/index.ts +42 -0
- package/src/markdown/createDescription.ts +13 -0
- package/src/markdown/schema.ts +115 -0
- package/src/markdown/utils.ts +39 -0
- package/src/theme/ApiDemoPanel/Accept/index.tsx +35 -0
- package/src/theme/ApiDemoPanel/Accept/slice.ts +29 -0
- package/src/theme/ApiDemoPanel/Authorization/auth-types.ts +26 -0
- package/src/theme/ApiDemoPanel/Authorization/index.tsx +211 -0
- package/src/theme/ApiDemoPanel/Authorization/slice.ts +145 -0
- package/src/theme/ApiDemoPanel/Body/index.tsx +218 -0
- package/src/theme/ApiDemoPanel/Body/slice.ts +133 -0
- package/src/theme/ApiDemoPanel/ContentType/index.tsx +35 -0
- package/src/theme/ApiDemoPanel/ContentType/slice.ts +29 -0
- package/src/theme/ApiDemoPanel/Curl/index.tsx +280 -0
- package/src/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/src/theme/ApiDemoPanel/Execute/index.tsx +88 -0
- package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +184 -0
- package/src/theme/ApiDemoPanel/FloatingButton/index.tsx +27 -0
- package/src/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/src/theme/ApiDemoPanel/FormFileUpload/index.tsx +116 -0
- package/src/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/src/theme/ApiDemoPanel/FormItem/index.tsx +28 -0
- package/src/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/src/theme/ApiDemoPanel/FormMultiSelect/index.tsx +54 -0
- package/src/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/src/theme/ApiDemoPanel/FormSelect/index.tsx +36 -0
- package/src/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/src/theme/ApiDemoPanel/FormTextInput/index.tsx +32 -0
- package/src/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/src/theme/ApiDemoPanel/MethodEndpoint/index.tsx +55 -0
- package/src/theme/ApiDemoPanel/ParamOptions/index.tsx +316 -0
- package/src/theme/ApiDemoPanel/ParamOptions/slice.ts +37 -0
- package/src/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/src/theme/ApiDemoPanel/Response/index.tsx +66 -0
- package/src/theme/ApiDemoPanel/Response/slice.ts +31 -0
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +49 -0
- package/src/theme/ApiDemoPanel/Server/index.tsx +103 -0
- package/src/theme/ApiDemoPanel/Server/slice.ts +40 -0
- package/src/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/src/theme/ApiDemoPanel/VSCode/index.tsx +205 -0
- package/src/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +307 -0
- package/src/theme/ApiDemoPanel/hooks.ts +13 -0
- package/src/theme/ApiDemoPanel/index.tsx +118 -0
- package/src/theme/ApiDemoPanel/persistanceMiddleware.ts +46 -0
- package/src/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/src/theme/ApiDemoPanel/storage-utils.ts +39 -0
- package/src/theme/ApiDemoPanel/store.ts +41 -0
- package/src/theme/ApiDemoPanel/styles.module.css +44 -0
- package/src/theme/ApiItem/index.tsx +171 -0
- package/src/theme/ApiItem/styles.module.css +109 -0
- package/src/theme/ParamsItem/index.js +68 -0
- package/src/theme/ParamsItem/styles.module.css +24 -0
- package/src/theme/SchemaItem/index.js +58 -0
- package/src/theme/SchemaItem/styles.module.css +24 -0
- package/src/theme/Tabs/index.js +258 -0
- package/src/theme/Tabs/styles.module.css +118 -0
- package/src/theme-classic.d.ts +8 -0
- package/src/theme-openapi.d.ts +48 -0
- package/src/theme-translations.d.ts +9 -0
- package/src/types.ts +70 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,284 @@
|
|
|
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
|
+
import React, { useState, useEffect } from "react";
|
|
8
|
+
import { nanoid } from "@reduxjs/toolkit";
|
|
9
|
+
import { useTypedDispatch, useTypedSelector } from "../hooks";
|
|
10
|
+
import FormItem from "./../FormItem";
|
|
11
|
+
import FormMultiSelect from "./../FormMultiSelect";
|
|
12
|
+
import FormSelect from "./../FormSelect";
|
|
13
|
+
import FormTextInput from "./../FormTextInput";
|
|
14
|
+
import { setParam } from "./slice";
|
|
15
|
+
import styles from "./styles.module.css";
|
|
16
|
+
|
|
17
|
+
function ParamOption({ param }) {
|
|
18
|
+
if (param.schema?.type === "array" && param.schema.items?.enum) {
|
|
19
|
+
return <ParamMultiSelectFormItem param={param} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (param.schema?.type === "array") {
|
|
23
|
+
return <ParamArrayFormItem param={param} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (param.schema?.enum) {
|
|
27
|
+
return <ParamSelectFormItem param={param} />;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (param.schema?.type === "boolean") {
|
|
31
|
+
return <ParamBooleanFormItem param={param} />;
|
|
32
|
+
} // integer, number, string, int32, int64, float, double, object, byte, binary,
|
|
33
|
+
// date-time, date, password
|
|
34
|
+
|
|
35
|
+
return <ParamTextFormItem param={param} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function ParamOptionWrapper({ param }) {
|
|
39
|
+
return (
|
|
40
|
+
<FormItem label={param.name} type={param.in}>
|
|
41
|
+
<ParamOption param={param} />
|
|
42
|
+
</FormItem>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function ParamOptions() {
|
|
47
|
+
const [showOptional, setShowOptional] = useState(false);
|
|
48
|
+
const pathParams = useTypedSelector((state) => state.params.path);
|
|
49
|
+
const queryParams = useTypedSelector((state) => state.params.query);
|
|
50
|
+
const cookieParams = useTypedSelector((state) => state.params.cookie);
|
|
51
|
+
const headerParams = useTypedSelector((state) => state.params.header);
|
|
52
|
+
const allParams = [
|
|
53
|
+
...pathParams,
|
|
54
|
+
...queryParams,
|
|
55
|
+
...cookieParams,
|
|
56
|
+
...headerParams,
|
|
57
|
+
];
|
|
58
|
+
const requiredParams = allParams.filter((p) => p.required);
|
|
59
|
+
const optionalParams = allParams.filter((p) => !p.required);
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
{/* Required Parameters */}
|
|
63
|
+
{requiredParams.map((param) => (
|
|
64
|
+
<ParamOptionWrapper key={`${param.in}-${param.name}`} param={param} />
|
|
65
|
+
))}
|
|
66
|
+
|
|
67
|
+
{/* Optional Parameters */}
|
|
68
|
+
{optionalParams.length > 0 && (
|
|
69
|
+
<>
|
|
70
|
+
<button
|
|
71
|
+
className={styles.showMoreButton}
|
|
72
|
+
onClick={() => setShowOptional((prev) => !prev)}
|
|
73
|
+
>
|
|
74
|
+
<span
|
|
75
|
+
style={{
|
|
76
|
+
width: "1.5em",
|
|
77
|
+
display: "inline-block",
|
|
78
|
+
textAlign: "center",
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<span
|
|
82
|
+
className={showOptional ? styles.plusExpanded : styles.plus}
|
|
83
|
+
>
|
|
84
|
+
<div>
|
|
85
|
+
<svg
|
|
86
|
+
style={{
|
|
87
|
+
fill: "currentColor",
|
|
88
|
+
width: "10px",
|
|
89
|
+
height: "10px",
|
|
90
|
+
}}
|
|
91
|
+
height="16"
|
|
92
|
+
viewBox="0 0 16 16"
|
|
93
|
+
width="16"
|
|
94
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
95
|
+
>
|
|
96
|
+
<path
|
|
97
|
+
d="M9 7h6a1 1 0 0 1 0 2H9v6a1 1 0 0 1-2 0V9H1a1 1 0 1 1 0-2h6V1a1 1 0 1 1 2 0z"
|
|
98
|
+
fillRule="evenodd"
|
|
99
|
+
></path>
|
|
100
|
+
</svg>
|
|
101
|
+
</div>
|
|
102
|
+
</span>
|
|
103
|
+
</span>
|
|
104
|
+
{showOptional
|
|
105
|
+
? "Hide optional parameters"
|
|
106
|
+
: "Show optional parameters"}
|
|
107
|
+
</button>
|
|
108
|
+
|
|
109
|
+
<div
|
|
110
|
+
className={showOptional ? styles.showOptions : styles.hideOptions}
|
|
111
|
+
>
|
|
112
|
+
{optionalParams.map((param) => (
|
|
113
|
+
<ParamOptionWrapper
|
|
114
|
+
key={`${param.in}-${param.name}`}
|
|
115
|
+
param={param}
|
|
116
|
+
/>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
</>
|
|
120
|
+
)}
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function ArrayItem({ param, onChange }) {
|
|
126
|
+
if (param.schema?.items?.type === "boolean") {
|
|
127
|
+
return (
|
|
128
|
+
<FormSelect
|
|
129
|
+
options={["---", "true", "false"]}
|
|
130
|
+
onChange={(e) => {
|
|
131
|
+
const val = e.target.value;
|
|
132
|
+
onChange(val === "---" ? undefined : val);
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<FormTextInput
|
|
140
|
+
placeholder={param.description || param.name}
|
|
141
|
+
onChange={(e) => {
|
|
142
|
+
onChange(e.target.value);
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function ParamArrayFormItem({ param }) {
|
|
149
|
+
const [items, setItems] = useState([]);
|
|
150
|
+
const dispatch = useTypedDispatch();
|
|
151
|
+
|
|
152
|
+
function handleAddItem() {
|
|
153
|
+
setItems((i) => [
|
|
154
|
+
...i,
|
|
155
|
+
{
|
|
156
|
+
id: nanoid(),
|
|
157
|
+
},
|
|
158
|
+
]);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const values = items.map((item) => item.value).filter((item) => !!item);
|
|
163
|
+
dispatch(
|
|
164
|
+
setParam({ ...param, value: values.length > 0 ? values : undefined })
|
|
165
|
+
); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
|
+
}, [items]);
|
|
167
|
+
|
|
168
|
+
function handleDeleteItem(itemToDelete) {
|
|
169
|
+
return () => {
|
|
170
|
+
const newItems = items.filter((i) => i.id !== itemToDelete.id);
|
|
171
|
+
setItems(newItems);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function handleChangeItem(itemToUpdate) {
|
|
176
|
+
return (value) => {
|
|
177
|
+
const newItems = items.map((i) => {
|
|
178
|
+
if (i.id === itemToUpdate.id) {
|
|
179
|
+
return { ...i, value: value };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return i;
|
|
183
|
+
});
|
|
184
|
+
setItems(newItems);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<>
|
|
190
|
+
{items.map((item) => (
|
|
191
|
+
<div
|
|
192
|
+
key={item.id}
|
|
193
|
+
style={{
|
|
194
|
+
display: "flex",
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
<ArrayItem param={param} onChange={handleChangeItem(item)} />
|
|
198
|
+
<button
|
|
199
|
+
className={styles.buttonDelete}
|
|
200
|
+
onClick={handleDeleteItem(item)}
|
|
201
|
+
>
|
|
202
|
+
<svg
|
|
203
|
+
focusable="false"
|
|
204
|
+
preserveAspectRatio="xMidYMid meet"
|
|
205
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
206
|
+
fill="currentColor"
|
|
207
|
+
width="16"
|
|
208
|
+
height="16"
|
|
209
|
+
viewBox="0 0 32 32"
|
|
210
|
+
aria-hidden="true"
|
|
211
|
+
>
|
|
212
|
+
<path d="M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z"></path>
|
|
213
|
+
<title>Delete</title>
|
|
214
|
+
</svg>
|
|
215
|
+
</button>
|
|
216
|
+
</div>
|
|
217
|
+
))}
|
|
218
|
+
<button className={styles.buttonThin} onClick={handleAddItem}>
|
|
219
|
+
Add item
|
|
220
|
+
</button>
|
|
221
|
+
</>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function ParamSelectFormItem({ param }) {
|
|
226
|
+
const dispatch = useTypedDispatch();
|
|
227
|
+
const options = param.schema?.enum ?? [];
|
|
228
|
+
return (
|
|
229
|
+
<FormSelect
|
|
230
|
+
options={["---", ...options]}
|
|
231
|
+
onChange={(e) => {
|
|
232
|
+
const val = e.target.value;
|
|
233
|
+
dispatch(
|
|
234
|
+
setParam({ ...param, value: val === "---" ? undefined : val })
|
|
235
|
+
);
|
|
236
|
+
}}
|
|
237
|
+
/>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function ParamBooleanFormItem({ param }) {
|
|
242
|
+
const dispatch = useTypedDispatch();
|
|
243
|
+
return (
|
|
244
|
+
<FormSelect
|
|
245
|
+
options={["---", "true", "false"]}
|
|
246
|
+
onChange={(e) => {
|
|
247
|
+
const val = e.target.value;
|
|
248
|
+
dispatch(
|
|
249
|
+
setParam({ ...param, value: val === "---" ? undefined : val })
|
|
250
|
+
);
|
|
251
|
+
}}
|
|
252
|
+
/>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function ParamMultiSelectFormItem({ param }) {
|
|
257
|
+
const dispatch = useTypedDispatch();
|
|
258
|
+
const options = param.schema?.items?.enum ?? [];
|
|
259
|
+
return (
|
|
260
|
+
<FormMultiSelect
|
|
261
|
+
options={options}
|
|
262
|
+
onChange={(e) => {
|
|
263
|
+
const values = Array.prototype.filter
|
|
264
|
+
.call(e.target.options, (o) => o.selected)
|
|
265
|
+
.map((o) => o.value);
|
|
266
|
+
dispatch(
|
|
267
|
+
setParam({ ...param, value: values.length > 0 ? values : undefined })
|
|
268
|
+
);
|
|
269
|
+
}}
|
|
270
|
+
/>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function ParamTextFormItem({ param }) {
|
|
275
|
+
const dispatch = useTypedDispatch();
|
|
276
|
+
return (
|
|
277
|
+
<FormTextInput
|
|
278
|
+
placeholder={param.description || param.name}
|
|
279
|
+
onChange={(e) => dispatch(setParam({ ...param, value: e.target.value }))}
|
|
280
|
+
/>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export default ParamOptions;
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
8
|
+
const initialState = {};
|
|
9
|
+
export const slice = createSlice({
|
|
10
|
+
name: "params",
|
|
11
|
+
initialState,
|
|
12
|
+
reducers: {
|
|
13
|
+
setParam: (state, action) => {
|
|
14
|
+
const newParam = action.payload;
|
|
15
|
+
const paramGroup = state[action.payload.in];
|
|
16
|
+
const index = paramGroup.findIndex((p) => p.name === newParam.name);
|
|
17
|
+
paramGroup[index] = newParam;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
export const { setParam } = slice.actions;
|
|
22
|
+
export default slice.reducer;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
.plus {
|
|
2
|
+
transition: transform 0.2s ease;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
transform: rotate(0deg);
|
|
5
|
+
transform-origin: center;
|
|
6
|
+
margin-right: 6px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.plusExpanded {
|
|
10
|
+
composes: plus;
|
|
11
|
+
transform: rotate(45deg);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.showMoreButton {
|
|
15
|
+
-webkit-appearance: none;
|
|
16
|
+
-moz-appearance: none;
|
|
17
|
+
appearance: none;
|
|
18
|
+
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
font-size: var(--ifm-code-font-size);
|
|
21
|
+
/* font-weight: var(--ifm-button-font-weight); */
|
|
22
|
+
/* line-height: 1.5; */
|
|
23
|
+
|
|
24
|
+
padding: 0;
|
|
25
|
+
|
|
26
|
+
user-select: none;
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
|
|
29
|
+
border: 0px solid transparent;
|
|
30
|
+
|
|
31
|
+
display: block;
|
|
32
|
+
width: 100%;
|
|
33
|
+
|
|
34
|
+
background-color: transparent;
|
|
35
|
+
|
|
36
|
+
color: var(--ifm-color-primary);
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
margin-top: var(--ifm-pre-padding);
|
|
39
|
+
margin-bottom: 0;
|
|
40
|
+
text-align: left;
|
|
41
|
+
display: block;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.showMoreButton:focus {
|
|
45
|
+
outline: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.showMoreButton:hover {
|
|
49
|
+
/* text-decoration: underline; */
|
|
50
|
+
/* background-color: red; */
|
|
51
|
+
color: var(--ifm-color-primary-hover);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.showMoreButton:first-child {
|
|
55
|
+
margin-top: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* .showMoreButton:last-child {
|
|
59
|
+
margin-bottom: 0;
|
|
60
|
+
} */
|
|
61
|
+
|
|
62
|
+
.buttonDelete {
|
|
63
|
+
-webkit-appearance: none;
|
|
64
|
+
-moz-appearance: none;
|
|
65
|
+
appearance: none;
|
|
66
|
+
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
font-size: calc(0.875rem * var(--ifm-button-size-multiplier));
|
|
69
|
+
font-weight: normal;
|
|
70
|
+
line-height: 1.5;
|
|
71
|
+
|
|
72
|
+
transition-property: color, background, border-color, box-shadow;
|
|
73
|
+
transition-duration: 100ms, 100ms, 100ms,
|
|
74
|
+
var(--ifm-button-transition-duration);
|
|
75
|
+
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
76
|
+
|
|
77
|
+
-webkit-user-select: none;
|
|
78
|
+
user-select: none;
|
|
79
|
+
white-space: nowrap;
|
|
80
|
+
|
|
81
|
+
display: flex;
|
|
82
|
+
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
|
|
86
|
+
padding: 0 12px;
|
|
87
|
+
|
|
88
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
89
|
+
background-color: var(--openapi-input-background);
|
|
90
|
+
border: none;
|
|
91
|
+
outline: none;
|
|
92
|
+
color: var(--ifm-pre-color);
|
|
93
|
+
border-radius: 4px;
|
|
94
|
+
margin-left: 4px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.buttonDelete:focus {
|
|
98
|
+
outline: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.buttonDelete:active {
|
|
102
|
+
box-shadow: inset 0px 0px 0px 2px var(--openapi-input-border);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.buttonThin {
|
|
106
|
+
-webkit-appearance: none;
|
|
107
|
+
-moz-appearance: none;
|
|
108
|
+
appearance: none;
|
|
109
|
+
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
font-size: calc(0.875rem * var(--ifm-button-size-multiplier));
|
|
112
|
+
font-weight: normal;
|
|
113
|
+
line-height: 1.5;
|
|
114
|
+
|
|
115
|
+
transition-property: color, background, border-color, box-shadow;
|
|
116
|
+
transition-duration: 100ms, 100ms, 100ms,
|
|
117
|
+
var(--ifm-button-transition-duration);
|
|
118
|
+
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
119
|
+
|
|
120
|
+
-webkit-user-select: none;
|
|
121
|
+
user-select: none;
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
|
|
124
|
+
background-color: transparent;
|
|
125
|
+
color: var(--openapi-input-border);
|
|
126
|
+
border: 1px solid var(--openapi-input-border);
|
|
127
|
+
border-radius: var(--ifm-pre-border-radius);
|
|
128
|
+
/* height: 48px; */
|
|
129
|
+
padding: 3px 60px 3px 12px;
|
|
130
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
131
|
+
margin-bottom: var(--ifm-pre-padding);
|
|
132
|
+
|
|
133
|
+
display: block;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.buttonThin:hover {
|
|
137
|
+
color: var(--openapi-inverse-color);
|
|
138
|
+
background-color: var(--openapi-input-border);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.buttonThin:focus {
|
|
142
|
+
outline: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.buttonThin:active {
|
|
146
|
+
box-shadow: inset 0 0 0 1px var(--openapi-input-border),
|
|
147
|
+
inset 0 0 0 2px var(--openapi-inverse-color);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.inputBase {
|
|
151
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
152
|
+
/* height: 40px; */
|
|
153
|
+
background-color: var(--openapi-input-background);
|
|
154
|
+
border: none;
|
|
155
|
+
outline: none;
|
|
156
|
+
width: 100%;
|
|
157
|
+
font-size: var(--ifm-code-font-size);
|
|
158
|
+
color: var(--ifm-pre-color);
|
|
159
|
+
padding: 12px var(--ifm-pre-padding);
|
|
160
|
+
|
|
161
|
+
border-radius: 4px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.input {
|
|
165
|
+
composes: inputBase;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.input:focus {
|
|
169
|
+
box-shadow: inset 0px 0px 0px 2px var(--openapi-input-border);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.showOptions {
|
|
173
|
+
visibility: visible;
|
|
174
|
+
margin-top: var(--ifm-pre-padding);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.hideOptions {
|
|
178
|
+
display: none;
|
|
179
|
+
visibility: hidden;
|
|
180
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
import React from "react";
|
|
8
|
+
import { useTypedDispatch, useTypedSelector } from "../hooks";
|
|
9
|
+
import FloatingButton from "./../FloatingButton";
|
|
10
|
+
import { clearResponse } from "./slice"; // TODO: We probably shouldn't attempt to format XML...
|
|
11
|
+
|
|
12
|
+
function formatXml(xml) {
|
|
13
|
+
const tab = " ";
|
|
14
|
+
let formatted = "";
|
|
15
|
+
let indent = "";
|
|
16
|
+
xml.split(/>\s*</).forEach((node) => {
|
|
17
|
+
if (node.match(/^\/\w/)) {
|
|
18
|
+
// decrease indent by one 'tab'
|
|
19
|
+
indent = indent.substring(tab.length);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
formatted += indent + "<" + node + ">\r\n";
|
|
23
|
+
|
|
24
|
+
if (node.match(/^<?\w[^>]*[^/]$/)) {
|
|
25
|
+
// increase indent
|
|
26
|
+
indent += tab;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return formatted.substring(1, formatted.length - 3);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function Response() {
|
|
33
|
+
const response = useTypedSelector((state) => state.response.value);
|
|
34
|
+
const dispatch = useTypedDispatch();
|
|
35
|
+
|
|
36
|
+
if (response === undefined) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let prettyResponse = response;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
prettyResponse = JSON.stringify(JSON.parse(response), null, 2);
|
|
44
|
+
} catch {
|
|
45
|
+
if (response.startsWith("<?xml ")) {
|
|
46
|
+
prettyResponse = formatXml(response);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<FloatingButton onClick={() => dispatch(clearResponse())} label="Clear">
|
|
52
|
+
<pre
|
|
53
|
+
style={{
|
|
54
|
+
background: "var(--openapi-card-background-color)",
|
|
55
|
+
borderRadius: "var(--openapi-card-border-radius)",
|
|
56
|
+
paddingRight: "60px",
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
<code>{prettyResponse || "No Response"}</code>
|
|
60
|
+
</pre>
|
|
61
|
+
</FloatingButton>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default Response;
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
8
|
+
const initialState = {};
|
|
9
|
+
export const slice = createSlice({
|
|
10
|
+
name: "response",
|
|
11
|
+
initialState,
|
|
12
|
+
reducers: {
|
|
13
|
+
setResponse: (state, action) => {
|
|
14
|
+
state.value = action.payload;
|
|
15
|
+
},
|
|
16
|
+
clearResponse: (state) => {
|
|
17
|
+
state.value = undefined;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
export const { setResponse, clearResponse } = slice.actions;
|
|
22
|
+
export default slice.reducer;
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
import React from "react";
|
|
8
|
+
import { useTypedSelector } from "../hooks";
|
|
9
|
+
|
|
10
|
+
function SecuritySchemes() {
|
|
11
|
+
const options = useTypedSelector((state) => state.auth.options);
|
|
12
|
+
const selected = useTypedSelector((state) => state.auth.selected);
|
|
13
|
+
if (selected === undefined) return null;
|
|
14
|
+
const selectedAuth = options[selected];
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
style={{
|
|
18
|
+
marginBottom: "var(--ifm-table-cell-padding)",
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
{selectedAuth.map((auth) => {
|
|
22
|
+
if (auth.type === "apiKey") {
|
|
23
|
+
return (
|
|
24
|
+
<React.Fragment key={selected + "-apiKey"}>
|
|
25
|
+
<b>Authorization: {auth.name}</b>
|
|
26
|
+
<pre
|
|
27
|
+
style={{
|
|
28
|
+
display: "flex",
|
|
29
|
+
flexDirection: "column",
|
|
30
|
+
background: "var(--openapi-card-background-color)",
|
|
31
|
+
borderRadius: "var(--openapi-card-border-radius)",
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
<span>name: {auth.name}</span>
|
|
35
|
+
<span>in: {auth.in}</span>
|
|
36
|
+
<span>type: {auth.type}</span>
|
|
37
|
+
</pre>
|
|
38
|
+
</React.Fragment>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
})}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default SecuritySchemes;
|