docusaurus-theme-openapi-docs 4.7.0 → 5.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/lib/index.js +2 -0
- package/lib/markdown/schema.js +63 -9
- package/lib/theme/ApiExplorer/Accept/index.js +2 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +6 -2
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +191 -38
- package/lib/theme/ApiExplorer/Body/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/index.js +86 -15
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +15 -16
- package/lib/theme/ApiExplorer/ContentType/index.js +7 -2
- package/lib/theme/ApiExplorer/EncodingSelection/slice.d.ts +17 -0
- package/lib/theme/ApiExplorer/EncodingSelection/slice.js +29 -0
- package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.d.ts +12 -0
- package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.js +39 -0
- 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/MethodEndpoint/index.js +28 -0
- 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 +6 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +6 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +8 -3
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.js +55 -5
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/lib/theme/ApiExplorer/Request/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/index.js +19 -5
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +3 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +19 -3
- package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/lib/theme/ApiExplorer/Response/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Response/index.js +98 -12
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +2 -2
- package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/Server/index.js +6 -3
- package/lib/theme/ApiExplorer/Server/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +5 -2
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -5
- package/lib/theme/ApiExplorer/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/index.js +1 -0
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
- package/lib/theme/ApiItem/hooks.d.ts +1 -0
- package/lib/theme/ApiItem/index.js +2 -1
- package/lib/theme/ApiItem/store.d.ts +6 -0
- package/lib/theme/ApiItem/store.js +11 -7
- package/lib/theme/ApiTabs/index.js +10 -11
- package/lib/theme/DiscriminatorTabs/index.js +10 -11
- package/lib/theme/MimeTabs/index.js +10 -11
- package/lib/theme/OperationTabs/index.js +10 -11
- package/lib/theme/ParamsDetails/index.js +2 -2
- package/lib/theme/ParamsItem/index.js +27 -0
- package/lib/theme/RequestSchema/index.d.ts +1 -1
- package/lib/theme/RequestSchema/index.js +174 -111
- package/lib/theme/ResponseHeaders/index.js +0 -1
- package/lib/theme/ResponseSchema/index.d.ts +1 -1
- package/lib/theme/Schema/index.d.ts +1 -1
- package/lib/theme/Schema/index.js +91 -23
- package/lib/theme/SchemaItem/index.js +6 -1
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +31 -12
- package/lib/theme/StatusCodes/index.d.ts +1 -1
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +3 -0
- package/lib/theme/translationIds.js +3 -0
- package/package.json +9 -8
- package/src/index.ts +2 -0
- package/src/markdown/schema.ts +69 -13
- package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +2 -5
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +119 -39
- package/src/theme/ApiExplorer/Body/index.tsx +88 -21
- package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +1 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +9 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +19 -19
- package/src/theme/ApiExplorer/ContentType/index.tsx +7 -4
- package/src/theme/ApiExplorer/EncodingSelection/slice.ts +31 -0
- package/src/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.ts +43 -0
- package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/src/theme/ApiExplorer/FormItem/index.tsx +2 -17
- 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/MethodEndpoint/index.tsx +21 -0
- 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 +14 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +16 -3
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +97 -11
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/src/theme/ApiExplorer/Request/index.tsx +22 -10
- package/src/theme/ApiExplorer/Request/makeRequest.ts +19 -3
- package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/src/theme/ApiExplorer/Response/index.tsx +37 -17
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +2 -3
- package/src/theme/ApiExplorer/Server/index.tsx +10 -3
- package/src/theme/ApiExplorer/Server/slice.ts +1 -1
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +53 -6
- package/src/theme/ApiExplorer/index.tsx +2 -1
- package/src/theme/ApiItem/index.tsx +3 -2
- package/src/theme/ApiItem/store.ts +2 -0
- package/src/theme/ApiTabs/index.tsx +14 -19
- package/src/theme/DiscriminatorTabs/index.tsx +14 -19
- package/src/theme/MimeTabs/index.tsx +15 -19
- package/src/theme/OperationTabs/index.tsx +14 -19
- package/src/theme/ParamsDetails/index.tsx +2 -3
- package/src/theme/ParamsItem/index.tsx +25 -0
- package/src/theme/RequestSchema/index.tsx +144 -87
- package/src/theme/ResponseHeaders/index.tsx +1 -2
- package/src/theme/ResponseSchema/index.tsx +1 -1
- package/src/theme/Schema/index.tsx +112 -27
- package/src/theme/SchemaItem/index.tsx +6 -1
- package/src/theme/SchemaTabs/index.tsx +42 -21
- package/src/theme/StatusCodes/index.tsx +1 -1
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +3 -0
- package/src/theme-classic.d.ts +25 -1
- package/src/types.d.ts +15 -52
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,5 +6,7 @@ export declare class RequestError extends Error {
|
|
|
6
6
|
originalError?: Error;
|
|
7
7
|
constructor(type: RequestErrorType, message: string, originalError?: Error);
|
|
8
8
|
}
|
|
9
|
-
declare function makeRequest(request: sdk.Request, proxy: string | undefined, _body: Body, timeout?: number
|
|
9
|
+
declare function makeRequest(request: sdk.Request, proxy: string | undefined, _body: Body, timeout?: number, credentials?: RequestCredentials, encoding?: Record<string, {
|
|
10
|
+
contentType?: string;
|
|
11
|
+
}>): Promise<Response>;
|
|
10
12
|
export default makeRequest;
|
|
@@ -89,7 +89,9 @@ async function makeRequest(
|
|
|
89
89
|
request,
|
|
90
90
|
proxy,
|
|
91
91
|
_body,
|
|
92
|
-
timeout = DEFAULT_REQUEST_TIMEOUT
|
|
92
|
+
timeout = DEFAULT_REQUEST_TIMEOUT,
|
|
93
|
+
credentials,
|
|
94
|
+
encoding
|
|
93
95
|
) {
|
|
94
96
|
const headers = request.toJSON().header;
|
|
95
97
|
let myHeaders = new Headers();
|
|
@@ -196,12 +198,25 @@ async function makeRequest(
|
|
|
196
198
|
const members = request.body?.formdata?.members;
|
|
197
199
|
if (Array.isArray(members)) {
|
|
198
200
|
for (const data of members) {
|
|
201
|
+
const partContentType = encoding?.[data.key]?.contentType
|
|
202
|
+
?.split(",")[0]
|
|
203
|
+
.trim();
|
|
199
204
|
if (data.key && data.value.content) {
|
|
200
|
-
|
|
205
|
+
const blob = partContentType
|
|
206
|
+
? new Blob([data.value.content], { type: partContentType })
|
|
207
|
+
: data.value.content;
|
|
208
|
+
myBody.append(data.key, blob);
|
|
201
209
|
}
|
|
202
210
|
// handle generic key-value payload
|
|
203
211
|
if (data.key && typeof data.value === "string") {
|
|
204
|
-
|
|
212
|
+
if (partContentType) {
|
|
213
|
+
myBody.append(
|
|
214
|
+
data.key,
|
|
215
|
+
new Blob([data.value], { type: partContentType })
|
|
216
|
+
);
|
|
217
|
+
} else {
|
|
218
|
+
myBody.append(data.key, data.value);
|
|
219
|
+
}
|
|
205
220
|
}
|
|
206
221
|
}
|
|
207
222
|
}
|
|
@@ -221,6 +236,7 @@ async function makeRequest(
|
|
|
221
236
|
method: request.method,
|
|
222
237
|
headers: myHeaders,
|
|
223
238
|
body: myBody,
|
|
239
|
+
...(credentials && { credentials }),
|
|
224
240
|
};
|
|
225
241
|
let finalUrl = request.url.toString();
|
|
226
242
|
if (proxy) {
|
|
@@ -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
|
}
|
|
@@ -5,6 +5,62 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
(function () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
@@ -14,7 +70,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
70
|
const react_1 = __importDefault(require("react"));
|
|
15
71
|
const client_1 = require("@docusaurus/plugin-content-docs/client");
|
|
16
72
|
const theme_common_1 = require("@docusaurus/theme-common");
|
|
17
|
-
const Translate_1 = require("@docusaurus/Translate");
|
|
73
|
+
const Translate_1 = __importStar(require("@docusaurus/Translate"));
|
|
18
74
|
const useDocusaurusContext_1 = __importDefault(
|
|
19
75
|
require("@docusaurus/useDocusaurusContext")
|
|
20
76
|
);
|
|
@@ -96,8 +152,9 @@ function Response({ item }) {
|
|
|
96
152
|
})
|
|
97
153
|
),
|
|
98
154
|
react_1.default.createElement(
|
|
99
|
-
"
|
|
155
|
+
"button",
|
|
100
156
|
{
|
|
157
|
+
type: "button",
|
|
101
158
|
className: "openapi-explorer__response-clear-btn",
|
|
102
159
|
onClick: () => {
|
|
103
160
|
dispatch((0, slice_1.clearResponse)());
|
|
@@ -157,11 +214,27 @@ function Response({ item }) {
|
|
|
157
214
|
className:
|
|
158
215
|
"openapi-explorer__response-placeholder-message",
|
|
159
216
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
217
|
+
react_1.default.createElement(
|
|
218
|
+
Translate_1.default,
|
|
219
|
+
{
|
|
220
|
+
id: translationIds_1.OPENAPI_RESPONSE.PLACEHOLDER,
|
|
221
|
+
values: {
|
|
222
|
+
code: react_1.default.createElement(
|
|
223
|
+
"code",
|
|
224
|
+
null,
|
|
225
|
+
react_1.default.createElement(
|
|
226
|
+
Translate_1.default,
|
|
227
|
+
{
|
|
228
|
+
id: translationIds_1.OPENAPI_REQUEST
|
|
229
|
+
.SEND_BUTTON,
|
|
230
|
+
},
|
|
231
|
+
"Send API Request"
|
|
232
|
+
)
|
|
233
|
+
),
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
"Click the {code} button above and see the response here!"
|
|
237
|
+
)
|
|
165
238
|
)
|
|
166
239
|
)
|
|
167
240
|
),
|
|
@@ -201,11 +274,24 @@ function Response({ item }) {
|
|
|
201
274
|
: react_1.default.createElement(
|
|
202
275
|
"p",
|
|
203
276
|
{ className: "openapi-explorer__response-placeholder-message" },
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
277
|
+
react_1.default.createElement(
|
|
278
|
+
Translate_1.default,
|
|
279
|
+
{
|
|
280
|
+
id: translationIds_1.OPENAPI_RESPONSE.PLACEHOLDER,
|
|
281
|
+
values: {
|
|
282
|
+
code: react_1.default.createElement(
|
|
283
|
+
"code",
|
|
284
|
+
null,
|
|
285
|
+
react_1.default.createElement(
|
|
286
|
+
Translate_1.default,
|
|
287
|
+
{ id: translationIds_1.OPENAPI_REQUEST.SEND_BUTTON },
|
|
288
|
+
"Send API Request"
|
|
289
|
+
)
|
|
290
|
+
),
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
"Click the {code} button above and see the response here!"
|
|
294
|
+
)
|
|
209
295
|
)
|
|
210
296
|
)
|
|
211
297
|
);
|
|
@@ -12,10 +12,10 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
-
const Translate_1 = require("@docusaurus/Translate");
|
|
16
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
17
15
|
const Link_1 = __importDefault(require("@docusaurus/Link"));
|
|
16
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
18
17
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
18
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
19
19
|
function SecuritySchemes(props) {
|
|
20
20
|
const options = (0, hooks_1.useTypedSelector)((state) => state.auth.options);
|
|
21
21
|
const selected = (0, hooks_1.useTypedSelector)(
|
|
@@ -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(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
-
import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
2
|
+
import type { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
3
3
|
export interface State {
|
|
4
4
|
value?: ServerObject;
|
|
5
5
|
options: ServerObject[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthState } from "@theme/ApiExplorer/Authorization/slice";
|
|
2
2
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
3
|
-
import { ParameterObject, ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
3
|
+
import type { ParameterObject, ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
4
4
|
import * as sdk from "postman-collection";
|
|
5
5
|
type Param = {
|
|
6
6
|
value?: string | string[];
|
|
@@ -15,6 +15,9 @@ interface Options {
|
|
|
15
15
|
accept: string;
|
|
16
16
|
body: Body;
|
|
17
17
|
auth: AuthState;
|
|
18
|
+
encoding?: Record<string, {
|
|
19
|
+
contentType?: string;
|
|
20
|
+
}>;
|
|
18
21
|
}
|
|
19
|
-
declare function buildPostmanRequest(postman: sdk.Request, { queryParams, pathParams, cookieParams, contentType, accept, headerParams, body, server, auth, }: Options): sdk.Request;
|
|
22
|
+
declare function buildPostmanRequest(postman: sdk.Request, { queryParams, pathParams, cookieParams, contentType, accept, headerParams, body, server, auth, encoding, }: Options): sdk.Request;
|
|
20
23
|
export default buildPostmanRequest;
|
|
@@ -314,11 +314,30 @@ function tryDecodeJsonParam(value) {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
// TODO: this is all a bit hacky
|
|
317
|
-
function setBody(clonedPostman, body) {
|
|
317
|
+
function setBody(clonedPostman, body, encoding) {
|
|
318
318
|
if (clonedPostman.body === undefined) {
|
|
319
319
|
return;
|
|
320
320
|
}
|
|
321
321
|
if (body.type === "empty") {
|
|
322
|
+
// When the original request has formdata and encoding is declared, keep the
|
|
323
|
+
// placeholder params so the code snippet reflects the selected encoding even
|
|
324
|
+
// before the user has uploaded a file.
|
|
325
|
+
if (
|
|
326
|
+
clonedPostman.body?.mode === "formdata" &&
|
|
327
|
+
encoding &&
|
|
328
|
+
Object.keys(encoding).length > 0
|
|
329
|
+
) {
|
|
330
|
+
const members = clonedPostman.body.formdata?.members ?? [];
|
|
331
|
+
members.forEach((param) => {
|
|
332
|
+
const partContentType = encoding[param.key]?.contentType
|
|
333
|
+
?.split(",")[0]
|
|
334
|
+
.trim();
|
|
335
|
+
if (partContentType) {
|
|
336
|
+
param.contentType = partContentType;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
322
341
|
clonedPostman.body = undefined;
|
|
323
342
|
return;
|
|
324
343
|
}
|
|
@@ -354,14 +373,35 @@ function setBody(clonedPostman, body) {
|
|
|
354
373
|
Object.entries(body.content)
|
|
355
374
|
.filter((entry) => !!entry[1])
|
|
356
375
|
.forEach(([key, content]) => {
|
|
376
|
+
const partContentType = encoding?.[key]?.contentType
|
|
377
|
+
?.split(",")[0]
|
|
378
|
+
.trim();
|
|
357
379
|
if (content.type === "file") {
|
|
358
|
-
params.push(
|
|
380
|
+
params.push(
|
|
381
|
+
new sdk.FormParam({
|
|
382
|
+
key: key,
|
|
383
|
+
...content,
|
|
384
|
+
...(partContentType && { contentType: partContentType }),
|
|
385
|
+
})
|
|
386
|
+
);
|
|
359
387
|
} else if (content.type === "file[]") {
|
|
360
388
|
content.value.forEach((file) =>
|
|
361
|
-
params.push(
|
|
389
|
+
params.push(
|
|
390
|
+
new sdk.FormParam({
|
|
391
|
+
key,
|
|
392
|
+
value: file,
|
|
393
|
+
...(partContentType && { contentType: partContentType }),
|
|
394
|
+
})
|
|
395
|
+
)
|
|
362
396
|
);
|
|
363
397
|
} else {
|
|
364
|
-
params.push(
|
|
398
|
+
params.push(
|
|
399
|
+
new sdk.FormParam({
|
|
400
|
+
key: key,
|
|
401
|
+
value: content.value,
|
|
402
|
+
...(partContentType && { contentType: partContentType }),
|
|
403
|
+
})
|
|
404
|
+
);
|
|
365
405
|
}
|
|
366
406
|
});
|
|
367
407
|
params.forEach((param) => {
|
|
@@ -409,6 +449,7 @@ function buildPostmanRequest(
|
|
|
409
449
|
body,
|
|
410
450
|
server,
|
|
411
451
|
auth,
|
|
452
|
+
encoding,
|
|
412
453
|
}
|
|
413
454
|
) {
|
|
414
455
|
const clonedPostman = (0, cloneDeep_1.default)(postman);
|
|
@@ -521,7 +562,7 @@ function buildPostmanRequest(
|
|
|
521
562
|
headerParams,
|
|
522
563
|
otherHeaders
|
|
523
564
|
);
|
|
524
|
-
setBody(clonedPostman, body);
|
|
565
|
+
setBody(clonedPostman, body, encoding);
|
|
525
566
|
return clonedPostman;
|
|
526
567
|
}
|
|
527
568
|
exports.default = buildPostmanRequest;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
2
|
+
import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
3
3
|
declare function ApiExplorer({ item, infoPath, }: {
|
|
4
4
|
item: NonNullable<ApiItem>;
|
|
5
5
|
infoPath: string;
|
|
@@ -99,6 +99,7 @@ function ApiExplorer({ item, infoPath }) {
|
|
|
99
99
|
postman: postman,
|
|
100
100
|
codeSamples: item["x-codeSamples"] ?? [],
|
|
101
101
|
maskCredentials: mask_credentials,
|
|
102
|
+
requestBody: item.requestBody,
|
|
102
103
|
}),
|
|
103
104
|
react_1.default.createElement(Request_1.default, { item: item }),
|
|
104
105
|
react_1.default.createElement(Response_1.default, { item: item })
|
|
@@ -3,6 +3,7 @@ import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
|
|
|
3
3
|
export declare function createPersistenceMiddleware(options: ThemeConfig["api"]): Middleware<{}, {
|
|
4
4
|
accept: import("./Accept/slice").State;
|
|
5
5
|
contentType: import("./ContentType/slice").State;
|
|
6
|
+
encodingSelection: import("./EncodingSelection/slice").State;
|
|
6
7
|
response: import("./Response/slice").State;
|
|
7
8
|
server: import("./Server/slice").State;
|
|
8
9
|
body: import("./Body/slice").FormBody | import("./Body/slice").RawBody | import("./Body/slice").EmptyBody;
|
|
@@ -12,6 +13,7 @@ export declare function createPersistenceMiddleware(options: ThemeConfig["api"])
|
|
|
12
13
|
}, import("redux-thunk").ThunkDispatch<{
|
|
13
14
|
accept: import("./Accept/slice").State;
|
|
14
15
|
contentType: import("./ContentType/slice").State;
|
|
16
|
+
encodingSelection: import("./EncodingSelection/slice").State;
|
|
15
17
|
response: import("./Response/slice").State;
|
|
16
18
|
server: import("./Server/slice").State;
|
|
17
19
|
body: import("./Body/slice").FormBody | import("./Body/slice").RawBody | import("./Body/slice").EmptyBody;
|
|
@@ -3,6 +3,7 @@ import type { RootState } from "./store";
|
|
|
3
3
|
export declare const useTypedDispatch: () => import("redux-thunk").ThunkDispatch<{
|
|
4
4
|
accept: import("../ApiExplorer/Accept/slice").State;
|
|
5
5
|
contentType: import("../ApiExplorer/ContentType/slice").State;
|
|
6
|
+
encodingSelection: import("../ApiExplorer/EncodingSelection/slice").State;
|
|
6
7
|
response: import("../ApiExplorer/Response/slice").State;
|
|
7
8
|
server: import("../ApiExplorer/Server/slice").State;
|
|
8
9
|
body: import("../ApiExplorer/Body/slice").FormBody | import("../ApiExplorer/Body/slice").RawBody | import("../ApiExplorer/Body/slice").EmptyBody;
|
|
@@ -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
|
|
103
|
+
paramsArray?.push(param);
|
|
104
104
|
});
|
|
105
105
|
const auth = (0, slice_1.createAuth)({
|
|
106
106
|
security: api?.security,
|
|
@@ -134,6 +134,7 @@ function ApiItem(props) {
|
|
|
134
134
|
params,
|
|
135
135
|
auth,
|
|
136
136
|
schemaSelection: { selections: {} },
|
|
137
|
+
encodingSelection: {},
|
|
137
138
|
},
|
|
138
139
|
[persistenceMiddleware]
|
|
139
140
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare const rootReducer: import("redux").Reducer<{
|
|
2
2
|
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
3
3
|
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
4
|
+
encodingSelection: import("@theme/ApiExplorer/EncodingSelection/slice").State;
|
|
4
5
|
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
5
6
|
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
6
7
|
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
@@ -10,6 +11,7 @@ declare const rootReducer: import("redux").Reducer<{
|
|
|
10
11
|
}, import("redux").UnknownAction, Partial<{
|
|
11
12
|
accept: import("@theme/ApiExplorer/Accept/slice").State | undefined;
|
|
12
13
|
contentType: import("@theme/ApiExplorer/ContentType/slice").State | undefined;
|
|
14
|
+
encodingSelection: import("@theme/ApiExplorer/EncodingSelection/slice").State | undefined;
|
|
13
15
|
response: import("@theme/ApiExplorer/Response/slice").State | undefined;
|
|
14
16
|
server: import("@theme/ApiExplorer/Server/slice").State | undefined;
|
|
15
17
|
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody | undefined;
|
|
@@ -21,6 +23,7 @@ export type RootState = ReturnType<typeof rootReducer>;
|
|
|
21
23
|
export declare const createStoreWithState: (preloadedState: RootState, middlewares: any[]) => import("@reduxjs/toolkit").EnhancedStore<{
|
|
22
24
|
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
23
25
|
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
26
|
+
encodingSelection: import("@theme/ApiExplorer/EncodingSelection/slice").State;
|
|
24
27
|
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
25
28
|
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
26
29
|
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
@@ -31,6 +34,7 @@ export declare const createStoreWithState: (preloadedState: RootState, middlewar
|
|
|
31
34
|
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
32
35
|
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
33
36
|
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
37
|
+
encodingSelection: import("@theme/ApiExplorer/EncodingSelection/slice").State;
|
|
34
38
|
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
35
39
|
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
36
40
|
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
@@ -42,6 +46,7 @@ export declare const createStoreWithState: (preloadedState: RootState, middlewar
|
|
|
42
46
|
export declare const createStoreWithoutState: (preloadedState: {}, middlewares: any[]) => import("@reduxjs/toolkit").EnhancedStore<{
|
|
43
47
|
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
44
48
|
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
49
|
+
encodingSelection: import("@theme/ApiExplorer/EncodingSelection/slice").State;
|
|
45
50
|
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
46
51
|
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
47
52
|
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
@@ -52,6 +57,7 @@ export declare const createStoreWithoutState: (preloadedState: {}, middlewares:
|
|
|
52
57
|
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
53
58
|
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
54
59
|
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
60
|
+
encodingSelection: import("@theme/ApiExplorer/EncodingSelection/slice").State;
|
|
55
61
|
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
56
62
|
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
57
63
|
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
@@ -22,22 +22,26 @@ const slice_4 = __importDefault(
|
|
|
22
22
|
require("@theme/ApiExplorer/ContentType/slice")
|
|
23
23
|
);
|
|
24
24
|
const slice_5 = __importDefault(
|
|
25
|
+
require("@theme/ApiExplorer/EncodingSelection/slice")
|
|
26
|
+
);
|
|
27
|
+
const slice_6 = __importDefault(
|
|
25
28
|
require("@theme/ApiExplorer/ParamOptions/slice")
|
|
26
29
|
);
|
|
27
|
-
const
|
|
28
|
-
const
|
|
30
|
+
const slice_7 = __importDefault(require("@theme/ApiExplorer/Response/slice"));
|
|
31
|
+
const slice_8 = __importDefault(
|
|
29
32
|
require("@theme/ApiExplorer/SchemaSelection/slice")
|
|
30
33
|
);
|
|
31
|
-
const
|
|
34
|
+
const slice_9 = __importDefault(require("@theme/ApiExplorer/Server/slice"));
|
|
32
35
|
const rootReducer = (0, toolkit_1.combineReducers)({
|
|
33
36
|
accept: slice_1.default,
|
|
34
37
|
contentType: slice_4.default,
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
encodingSelection: slice_5.default,
|
|
39
|
+
response: slice_7.default,
|
|
40
|
+
server: slice_9.default,
|
|
37
41
|
body: slice_3.default,
|
|
38
|
-
params:
|
|
42
|
+
params: slice_6.default,
|
|
39
43
|
auth: slice_2.default,
|
|
40
|
-
schemaSelection:
|
|
44
|
+
schemaSelection: slice_8.default,
|
|
41
45
|
});
|
|
42
46
|
const createStoreWithState = (preloadedState, middlewares) =>
|
|
43
47
|
(0, toolkit_1.configureStore)({
|
|
@@ -241,21 +241,20 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
241
241
|
return react_1.default.createElement(
|
|
242
242
|
"div",
|
|
243
243
|
{ className: "margin-top--md" },
|
|
244
|
-
childTabs
|
|
245
|
-
(0, react_1.cloneElement)(tabItem, {
|
|
246
|
-
key: i,
|
|
247
|
-
hidden: tabItem.props.value !== selectedValue,
|
|
248
|
-
})
|
|
249
|
-
)
|
|
244
|
+
childTabs
|
|
250
245
|
);
|
|
251
246
|
}
|
|
252
247
|
function TabsComponent(props) {
|
|
253
|
-
const tabs = (0, internal_1.
|
|
248
|
+
const tabs = (0, internal_1.useTabsContextValue)(props);
|
|
254
249
|
return react_1.default.createElement(
|
|
255
|
-
|
|
256
|
-
{
|
|
257
|
-
react_1.default.createElement(
|
|
258
|
-
|
|
250
|
+
internal_1.TabsProvider,
|
|
251
|
+
{ value: tabs },
|
|
252
|
+
react_1.default.createElement(
|
|
253
|
+
"div",
|
|
254
|
+
{ className: "openapi-tabs__container" },
|
|
255
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
256
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
257
|
+
)
|
|
259
258
|
);
|
|
260
259
|
}
|
|
261
260
|
function ApiTabs(props) {
|
|
@@ -219,21 +219,20 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
219
219
|
return react_1.default.createElement(
|
|
220
220
|
"div",
|
|
221
221
|
{ className: "margin-top--md" },
|
|
222
|
-
childTabs
|
|
223
|
-
(0, react_1.cloneElement)(tabItem, {
|
|
224
|
-
key: i,
|
|
225
|
-
hidden: tabItem.props.value !== selectedValue,
|
|
226
|
-
})
|
|
227
|
-
)
|
|
222
|
+
childTabs
|
|
228
223
|
);
|
|
229
224
|
}
|
|
230
225
|
function TabsComponent(props) {
|
|
231
|
-
const tabs = (0, internal_1.
|
|
226
|
+
const tabs = (0, internal_1.useTabsContextValue)(props);
|
|
232
227
|
return react_1.default.createElement(
|
|
233
|
-
|
|
234
|
-
{
|
|
235
|
-
react_1.default.createElement(
|
|
236
|
-
|
|
228
|
+
internal_1.TabsProvider,
|
|
229
|
+
{ value: tabs },
|
|
230
|
+
react_1.default.createElement(
|
|
231
|
+
"div",
|
|
232
|
+
{ className: "openapi-tabs__container" },
|
|
233
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
234
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
235
|
+
)
|
|
237
236
|
);
|
|
238
237
|
}
|
|
239
238
|
function DiscriminatorTabs(props) {
|
|
@@ -252,21 +252,20 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
252
252
|
return react_1.default.createElement(
|
|
253
253
|
"div",
|
|
254
254
|
{ className: "margin-top--md" },
|
|
255
|
-
childTabs
|
|
256
|
-
(0, react_1.cloneElement)(tabItem, {
|
|
257
|
-
key: i,
|
|
258
|
-
hidden: tabItem.props.value !== selectedValue,
|
|
259
|
-
})
|
|
260
|
-
)
|
|
255
|
+
childTabs
|
|
261
256
|
);
|
|
262
257
|
}
|
|
263
258
|
function TabsComponent(props) {
|
|
264
|
-
const tabs = (0, internal_1.
|
|
259
|
+
const tabs = (0, internal_1.useTabsContextValue)(props);
|
|
265
260
|
return react_1.default.createElement(
|
|
266
|
-
|
|
267
|
-
{
|
|
268
|
-
react_1.default.createElement(
|
|
269
|
-
|
|
261
|
+
internal_1.TabsProvider,
|
|
262
|
+
{ value: tabs },
|
|
263
|
+
react_1.default.createElement(
|
|
264
|
+
"div",
|
|
265
|
+
{ className: "tabs-container" },
|
|
266
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
267
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
268
|
+
)
|
|
270
269
|
);
|
|
271
270
|
}
|
|
272
271
|
function MimeTabs(props) {
|