docusaurus-theme-openapi-docs 4.5.0 → 4.6.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/markdown/schema.js +9 -1
- package/lib/theme/ApiExplorer/Accept/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/Authorization/index.js +50 -9
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +145 -3
- package/lib/theme/ApiExplorer/Authorization/slice.js +3 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +126 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +110 -0
- package/lib/theme/ApiExplorer/Body/index.js +94 -100
- package/lib/theme/ApiExplorer/Body/slice.d.ts +1056 -11
- package/lib/theme/ApiExplorer/Body/slice.js +22 -2
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +37 -26
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +3 -3
- package/lib/theme/ApiExplorer/CodeTabs/index.js +2 -2
- package/lib/theme/ApiExplorer/ContentType/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +6 -1
- package/lib/theme/ApiExplorer/FormItem/index.js +6 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.js +8 -1
- package/lib/theme/ApiExplorer/LiveEditor/index.js +11 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +15 -5
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +12 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +11 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +11 -1
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +0 -4
- package/lib/theme/ApiExplorer/ParamOptions/slice.js +4 -4
- package/lib/theme/ApiExplorer/Request/index.js +110 -17
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +7 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +94 -24
- package/lib/theme/ApiExplorer/Response/index.js +34 -14
- package/lib/theme/ApiExplorer/Response/slice.d.ts +31 -7
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +208 -69
- package/lib/theme/ApiExplorer/Server/index.js +16 -2
- package/lib/theme/ApiExplorer/Server/slice.d.ts +49 -3
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -57
- package/lib/theme/ApiExplorer/index.js +11 -1
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +19 -0
- package/lib/theme/ApiExplorer/{persistanceMiddleware.js → persistenceMiddleware.js} +16 -9
- package/lib/theme/ApiExplorer/storage-utils.d.ts +2 -2
- package/lib/theme/ApiExplorer/storage-utils.js +3 -3
- package/lib/theme/ApiItem/Layout/index.d.ts +1 -1
- package/lib/theme/ApiItem/hooks.d.ts +9 -9
- package/lib/theme/ApiItem/index.js +12 -8
- package/lib/theme/ApiItem/store.d.ts +55 -43
- package/lib/theme/ApiTabs/index.js +6 -1
- package/lib/theme/Example/_Example.scss +11 -0
- package/lib/theme/Example/index.d.ts +24 -0
- package/lib/theme/Example/index.js +170 -0
- package/lib/theme/ParamsDetails/index.js +9 -1
- package/lib/theme/ParamsItem/index.d.ts +1 -1
- package/lib/theme/ParamsItem/index.js +43 -74
- package/lib/theme/RequestSchema/index.js +18 -4
- package/lib/theme/ResponseExamples/index.js +23 -3
- package/lib/theme/ResponseSchema/index.js +97 -82
- package/lib/theme/Schema/index.js +106 -23
- package/lib/theme/SchemaItem/index.js +64 -36
- package/lib/theme/SchemaTabs/index.js +4 -1
- package/lib/theme/StatusCodes/index.js +11 -2
- package/lib/theme/styles.scss +5 -0
- package/lib/theme/translationIds.d.ts +90 -0
- package/lib/theme/translationIds.js +114 -0
- package/lib/types.d.ts +9 -1
- package/package.json +28 -28
- package/src/markdown/schema.ts +11 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +51 -10
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +77 -0
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +120 -0
- package/src/theme/ApiExplorer/Body/index.tsx +87 -107
- package/src/theme/ApiExplorer/Body/json2xml.d.ts +8 -0
- package/src/theme/ApiExplorer/Body/slice.ts +40 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +43 -29
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +6 -5
- package/src/theme/ApiExplorer/ContentType/index.tsx +1 -1
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +6 -1
- package/src/theme/ApiExplorer/FormItem/index.tsx +8 -1
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +10 -1
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +11 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +16 -6
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -3
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +10 -2
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/index.tsx +108 -17
- package/src/theme/ApiExplorer/Request/makeRequest.ts +106 -25
- package/src/theme/ApiExplorer/Response/index.tsx +30 -8
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +157 -69
- package/src/theme/ApiExplorer/Server/index.tsx +12 -4
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +47 -63
- package/src/theme/ApiExplorer/index.tsx +10 -1
- package/src/theme/ApiExplorer/{persistanceMiddleware.ts → persistenceMiddleware.ts} +23 -13
- package/src/theme/ApiExplorer/storage-utils.ts +4 -4
- package/src/theme/ApiItem/Layout/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +12 -7
- package/src/theme/ApiTabs/index.tsx +6 -1
- package/src/theme/Example/_Example.scss +11 -0
- package/src/theme/Example/index.tsx +168 -0
- package/src/theme/Markdown/index.d.ts +8 -0
- package/src/theme/ParamsDetails/index.tsx +10 -1
- package/src/theme/ParamsItem/index.tsx +38 -54
- package/src/theme/RequestSchema/index.tsx +19 -4
- package/src/theme/ResponseExamples/index.tsx +23 -3
- package/src/theme/ResponseSchema/index.tsx +73 -61
- package/src/theme/Schema/index.tsx +128 -33
- package/src/theme/SchemaItem/index.tsx +51 -33
- package/src/theme/SchemaTabs/index.tsx +4 -1
- package/src/theme/StatusCodes/index.tsx +13 -2
- package/src/theme/styles.scss +5 -0
- package/src/theme/translationIds.ts +111 -0
- package/src/theme-openapi.d.ts +7 -275
- package/src/types.ts +9 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +0 -3
|
@@ -103,18 +103,10 @@ function setQueryParams(postman, queryParams) {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
const decodedValue = decodeURI(param.value);
|
|
107
|
-
const tryJson = () => {
|
|
108
|
-
try {
|
|
109
|
-
return JSON.parse(decodedValue);
|
|
110
|
-
} catch (e) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const jsonResult = tryJson();
|
|
115
106
|
// Handle object values
|
|
116
|
-
if (
|
|
117
|
-
|
|
107
|
+
if (param.style === "deepObject") {
|
|
108
|
+
const jsonResult = tryDecodeJsonParam(param.value);
|
|
109
|
+
if (jsonResult && typeof jsonResult === "object") {
|
|
118
110
|
return Object.entries(jsonResult).map(
|
|
119
111
|
([key, val]) =>
|
|
120
112
|
new sdk.QueryParam({
|
|
@@ -122,7 +114,10 @@ function setQueryParams(postman, queryParams) {
|
|
|
122
114
|
value: String(val),
|
|
123
115
|
})
|
|
124
116
|
);
|
|
125
|
-
}
|
|
117
|
+
}
|
|
118
|
+
} else if (param.explode) {
|
|
119
|
+
const jsonResult = tryDecodeJsonParam(param.value);
|
|
120
|
+
if (jsonResult && typeof jsonResult === "object") {
|
|
126
121
|
return Object.entries(jsonResult).map(
|
|
127
122
|
([key, val]) =>
|
|
128
123
|
new sdk.QueryParam({
|
|
@@ -139,16 +134,9 @@ function setQueryParams(postman, queryParams) {
|
|
|
139
134
|
});
|
|
140
135
|
}
|
|
141
136
|
}
|
|
142
|
-
// Handle boolean values
|
|
143
|
-
if (typeof decodedValue === "boolean") {
|
|
144
|
-
return new sdk.QueryParam({
|
|
145
|
-
key: param.name,
|
|
146
|
-
value: decodedValue ? "true" : "false",
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
137
|
// Parameter allows empty value: "/hello?extended"
|
|
150
138
|
if (param.allowEmptyValue) {
|
|
151
|
-
if (
|
|
139
|
+
if (param.value === "true") {
|
|
152
140
|
return new sdk.QueryParam({
|
|
153
141
|
key: param.name,
|
|
154
142
|
value: null,
|
|
@@ -188,16 +176,8 @@ function setPathParams(postman, pathParams) {
|
|
|
188
176
|
value: serializedValue,
|
|
189
177
|
});
|
|
190
178
|
}
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
return JSON.parse(decodedValue);
|
|
195
|
-
} catch (e) {
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
const jsonResult = tryJson();
|
|
200
|
-
if (typeof jsonResult === "object") {
|
|
179
|
+
const jsonResult = tryDecodeJsonParam(param.value);
|
|
180
|
+
if (jsonResult && typeof jsonResult === "object") {
|
|
201
181
|
if (param.style === "matrix") {
|
|
202
182
|
serializedValue = Object.entries(jsonResult)
|
|
203
183
|
.map(([key, val]) => `;${key}=${val}`)
|
|
@@ -208,7 +188,7 @@ function setPathParams(postman, pathParams) {
|
|
|
208
188
|
.join(",");
|
|
209
189
|
}
|
|
210
190
|
} else {
|
|
211
|
-
serializedValue =
|
|
191
|
+
serializedValue = param.value;
|
|
212
192
|
}
|
|
213
193
|
return new sdk.Variable({
|
|
214
194
|
key: param.name,
|
|
@@ -224,16 +204,8 @@ function buildCookie(cookieParams) {
|
|
|
224
204
|
const cookies = cookieParams
|
|
225
205
|
.map((param) => {
|
|
226
206
|
if (param.value) {
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
try {
|
|
230
|
-
return JSON.parse(decodedValue);
|
|
231
|
-
} catch (e) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
const jsonResult = tryJson();
|
|
236
|
-
if (typeof jsonResult === "object") {
|
|
207
|
+
const jsonResult = tryDecodeJsonParam(param.value);
|
|
208
|
+
if (jsonResult && typeof jsonResult === "object") {
|
|
237
209
|
if (param.style === "form") {
|
|
238
210
|
// Handle form style
|
|
239
211
|
if (param.explode) {
|
|
@@ -286,15 +258,9 @@ function setHeaders(postman, contentType, accept, cookie, headerParams, other) {
|
|
|
286
258
|
}
|
|
287
259
|
headerParams.forEach((param) => {
|
|
288
260
|
if (param.value) {
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
return JSON.parse(decodedValue);
|
|
293
|
-
} catch (e) {
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
const jsonResult = tryJson();
|
|
261
|
+
const jsonResult = Array.isArray(param.value)
|
|
262
|
+
? param.value.map(tryDecodeJsonParam)
|
|
263
|
+
: tryDecodeJsonParam(param.value);
|
|
298
264
|
if (Array.isArray(param.value)) {
|
|
299
265
|
if (param.style === "simple") {
|
|
300
266
|
if (param.explode) {
|
|
@@ -340,6 +306,13 @@ function setHeaders(postman, contentType, accept, cookie, headerParams, other) {
|
|
|
340
306
|
postman.addHeader({ key: "Cookie", value: cookie });
|
|
341
307
|
}
|
|
342
308
|
}
|
|
309
|
+
function tryDecodeJsonParam(value) {
|
|
310
|
+
try {
|
|
311
|
+
return JSON.parse(decodeURI(value));
|
|
312
|
+
} catch (e) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
343
316
|
// TODO: this is all a bit hacky
|
|
344
317
|
function setBody(clonedPostman, body) {
|
|
345
318
|
if (clonedPostman.body === undefined) {
|
|
@@ -358,7 +331,11 @@ function setBody(clonedPostman, body) {
|
|
|
358
331
|
switch (clonedPostman.body.mode) {
|
|
359
332
|
case "raw": {
|
|
360
333
|
// check file even though it should already be set from above
|
|
361
|
-
if (
|
|
334
|
+
if (
|
|
335
|
+
body.type !== "raw" ||
|
|
336
|
+
body.content?.type === "file" ||
|
|
337
|
+
body.content?.type === "file[]"
|
|
338
|
+
) {
|
|
362
339
|
clonedPostman.body = undefined;
|
|
363
340
|
return;
|
|
364
341
|
}
|
|
@@ -373,15 +350,23 @@ function setBody(clonedPostman, body) {
|
|
|
373
350
|
clonedPostman.body.raw = `${body.content?.value}`;
|
|
374
351
|
return;
|
|
375
352
|
}
|
|
376
|
-
const params =
|
|
353
|
+
const params = [];
|
|
354
|
+
Object.entries(body.content)
|
|
377
355
|
.filter((entry) => !!entry[1])
|
|
378
|
-
.
|
|
356
|
+
.forEach(([key, content]) => {
|
|
379
357
|
if (content.type === "file") {
|
|
380
|
-
|
|
358
|
+
params.push(new sdk.FormParam({ key: key, ...content }));
|
|
359
|
+
} else if (content.type === "file[]") {
|
|
360
|
+
content.value.forEach((file) =>
|
|
361
|
+
params.push(new sdk.FormParam({ key, value: file }))
|
|
362
|
+
);
|
|
363
|
+
} else {
|
|
364
|
+
params.push(new sdk.FormParam({ key: key, value: content.value }));
|
|
381
365
|
}
|
|
382
|
-
return new sdk.FormParam({ key: key, value: content.value });
|
|
383
366
|
});
|
|
384
|
-
|
|
367
|
+
params.forEach((param) => {
|
|
368
|
+
clonedPostman.body?.formdata?.add(param);
|
|
369
|
+
});
|
|
385
370
|
return;
|
|
386
371
|
}
|
|
387
372
|
case "urlencoded": {
|
|
@@ -395,7 +380,11 @@ function setBody(clonedPostman, body) {
|
|
|
395
380
|
const params = Object.entries(body.content)
|
|
396
381
|
.filter((entry) => !!entry[1])
|
|
397
382
|
.map(([key, content]) => {
|
|
398
|
-
if (
|
|
383
|
+
if (
|
|
384
|
+
content.type !== "file" &&
|
|
385
|
+
content.type !== "file[]" &&
|
|
386
|
+
content.value
|
|
387
|
+
) {
|
|
399
388
|
return new sdk.QueryParam({ key: key, value: content.value });
|
|
400
389
|
}
|
|
401
390
|
return undefined;
|
|
@@ -68,6 +68,7 @@ var __importDefault =
|
|
|
68
68
|
};
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
const react_1 = __importDefault(require("react"));
|
|
71
|
+
const client_1 = require("@docusaurus/plugin-content-docs/client");
|
|
71
72
|
const CodeSnippets_1 = __importDefault(
|
|
72
73
|
require("@theme/ApiExplorer/CodeSnippets")
|
|
73
74
|
);
|
|
@@ -78,7 +79,15 @@ const SecuritySchemes_1 = __importDefault(
|
|
|
78
79
|
);
|
|
79
80
|
const sdk = __importStar(require("postman-collection"));
|
|
80
81
|
function ApiExplorer({ item, infoPath }) {
|
|
81
|
-
const
|
|
82
|
+
const metadata = (0, client_1.useDoc)();
|
|
83
|
+
const { mask_credentials } = metadata.frontMatter;
|
|
84
|
+
const postman = new sdk.Request(
|
|
85
|
+
item.postman
|
|
86
|
+
? sdk.Request.isRequest(item.postman)
|
|
87
|
+
? item.postman.toJSON()
|
|
88
|
+
: item.postman
|
|
89
|
+
: {}
|
|
90
|
+
);
|
|
82
91
|
return react_1.default.createElement(
|
|
83
92
|
react_1.default.Fragment,
|
|
84
93
|
null,
|
|
@@ -89,6 +98,7 @@ function ApiExplorer({ item, infoPath }) {
|
|
|
89
98
|
react_1.default.createElement(CodeSnippets_1.default, {
|
|
90
99
|
postman: postman,
|
|
91
100
|
codeSamples: item["x-codeSamples"] ?? [],
|
|
101
|
+
maskCredentials: mask_credentials,
|
|
92
102
|
}),
|
|
93
103
|
react_1.default.createElement(Request_1.default, { item: item }),
|
|
94
104
|
react_1.default.createElement(Response_1.default, { item: item })
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Middleware } from "@reduxjs/toolkit";
|
|
2
|
+
import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
|
|
3
|
+
export declare function createPersistenceMiddleware(options: ThemeConfig["api"]): Middleware<{}, {
|
|
4
|
+
accept: import("./Accept/slice").State;
|
|
5
|
+
contentType: import("./ContentType/slice").State;
|
|
6
|
+
response: import("./Response/slice").State;
|
|
7
|
+
server: import("./Server/slice").State;
|
|
8
|
+
body: import("./Body/slice").FormBody | import("./Body/slice").RawBody | import("./Body/slice").EmptyBody;
|
|
9
|
+
params: import("./ParamOptions/slice").State;
|
|
10
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
|
|
11
|
+
}, import("redux-thunk").ThunkDispatch<{
|
|
12
|
+
accept: import("./Accept/slice").State;
|
|
13
|
+
contentType: import("./ContentType/slice").State;
|
|
14
|
+
response: import("./Response/slice").State;
|
|
15
|
+
server: import("./Server/slice").State;
|
|
16
|
+
body: import("./Body/slice").FormBody | import("./Body/slice").RawBody | import("./Body/slice").EmptyBody;
|
|
17
|
+
params: import("./ParamOptions/slice").State;
|
|
18
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
|
|
19
|
+
}, undefined, import("redux").UnknownAction> & import("redux").Dispatch<import("redux").UnknownAction>>;
|
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.createPersistenceMiddleware = createPersistenceMiddleware;
|
|
10
10
|
const slice_1 = require("@theme/ApiExplorer/Authorization/slice");
|
|
11
11
|
const storage_utils_1 = require("./storage-utils");
|
|
12
|
-
function
|
|
13
|
-
const
|
|
12
|
+
function createPersistenceMiddleware(options) {
|
|
13
|
+
const persistenceMiddleware = (storeAPI) => (next) => (action) => {
|
|
14
14
|
const result = next(action);
|
|
15
15
|
const state = storeAPI.getState();
|
|
16
|
-
const storage = (0, storage_utils_1.createStorage)(
|
|
16
|
+
const storage = (0, storage_utils_1.createStorage)(
|
|
17
|
+
options?.authPersistence ?? "sessionStorage"
|
|
18
|
+
);
|
|
17
19
|
if (action.type === slice_1.setAuthData.type) {
|
|
18
20
|
for (const [key, value] of Object.entries(state.auth.data)) {
|
|
19
21
|
if (Object.values(value).filter(Boolean).length > 0) {
|
|
@@ -42,13 +44,18 @@ function createPersistanceMiddleware(options) {
|
|
|
42
44
|
storage.setItem("server", action.payload);
|
|
43
45
|
}
|
|
44
46
|
if (action.type === "server/setServerVariable") {
|
|
45
|
-
const server = storage.getItem("server")
|
|
47
|
+
const server = storage.getItem("server");
|
|
48
|
+
if (!server) {
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
46
51
|
const variables = JSON.parse(action.payload);
|
|
47
|
-
|
|
48
|
-
serverObject.variables[variables.key]
|
|
49
|
-
|
|
52
|
+
const serverObject = JSON.parse(server) ?? {};
|
|
53
|
+
if (serverObject.variables?.[variables.key]) {
|
|
54
|
+
serverObject.variables[variables.key].default = variables.value;
|
|
55
|
+
storage.setItem("server", JSON.stringify(serverObject));
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
return result;
|
|
52
59
|
};
|
|
53
|
-
return
|
|
60
|
+
return persistenceMiddleware;
|
|
54
61
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function hashArray(arr: string[]): string;
|
|
2
|
-
type
|
|
3
|
-
export declare function createStorage(
|
|
2
|
+
type Persistence = false | "localStorage" | "sessionStorage" | undefined;
|
|
3
|
+
export declare function createStorage(persistence: Persistence): Storage;
|
|
4
4
|
export {};
|
|
@@ -23,8 +23,8 @@ function hashArray(arr) {
|
|
|
23
23
|
const res = hashed.join();
|
|
24
24
|
return hash(res);
|
|
25
25
|
}
|
|
26
|
-
function createStorage(
|
|
27
|
-
if (
|
|
26
|
+
function createStorage(persistence) {
|
|
27
|
+
if (persistence === false) {
|
|
28
28
|
return {
|
|
29
29
|
getItem: () => null,
|
|
30
30
|
setItem: () => {},
|
|
@@ -34,7 +34,7 @@ function createStorage(persistance) {
|
|
|
34
34
|
length: 0,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
37
|
+
if (persistence === "sessionStorage") {
|
|
38
38
|
return sessionStorage;
|
|
39
39
|
}
|
|
40
40
|
return localStorage;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TypedUseSelectorHook } from "react-redux";
|
|
2
2
|
import type { RootState } from "./store";
|
|
3
|
-
export declare const useTypedDispatch: () => import("redux-thunk").ThunkDispatch<
|
|
4
|
-
accept:
|
|
5
|
-
contentType:
|
|
6
|
-
response:
|
|
7
|
-
server:
|
|
8
|
-
body:
|
|
9
|
-
params:
|
|
10
|
-
auth:
|
|
11
|
-
}
|
|
3
|
+
export declare const useTypedDispatch: () => import("redux-thunk").ThunkDispatch<{
|
|
4
|
+
accept: import("../ApiExplorer/Accept/slice").State;
|
|
5
|
+
contentType: import("../ApiExplorer/ContentType/slice").State;
|
|
6
|
+
response: import("../ApiExplorer/Response/slice").State;
|
|
7
|
+
server: import("../ApiExplorer/Server/slice").State;
|
|
8
|
+
body: import("../ApiExplorer/Body/slice").FormBody | import("../ApiExplorer/Body/slice").RawBody | import("../ApiExplorer/Body/slice").EmptyBody;
|
|
9
|
+
params: import("../ApiExplorer/ParamOptions/slice").State;
|
|
10
|
+
auth: import("../ApiExplorer/Authorization/slice").AuthState;
|
|
11
|
+
}, undefined, import("redux").UnknownAction> & import("redux").Dispatch<import("redux").UnknownAction>;
|
|
12
12
|
export declare const useTypedSelector: TypedUseSelectorHook<RootState>;
|
|
@@ -24,7 +24,8 @@ const useDocusaurusContext_1 = __importDefault(
|
|
|
24
24
|
);
|
|
25
25
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
26
26
|
const slice_1 = require("@theme/ApiExplorer/Authorization/slice");
|
|
27
|
-
const
|
|
27
|
+
const persistenceMiddleware_1 = require("@theme/ApiExplorer/persistenceMiddleware");
|
|
28
|
+
const storage_utils_1 = require("@theme/ApiExplorer/storage-utils");
|
|
28
29
|
const Layout_1 = __importDefault(require("@theme/ApiItem/Layout"));
|
|
29
30
|
const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
|
|
30
31
|
const Metadata_1 = __importDefault(require("@theme/DocItem/Metadata"));
|
|
@@ -71,11 +72,11 @@ function ApiItem(props) {
|
|
|
71
72
|
const statusRegex = new RegExp("(20[0-9]|2[1-9][0-9])");
|
|
72
73
|
// Define store2
|
|
73
74
|
let store2 = {};
|
|
74
|
-
const
|
|
75
|
-
|
|
75
|
+
const persistenceMiddleware = (0,
|
|
76
|
+
persistenceMiddleware_1.createPersistenceMiddleware)(options);
|
|
76
77
|
// Init store for SSR
|
|
77
78
|
if (!isBrowser) {
|
|
78
|
-
store2 = (0, store_1.createStoreWithoutState)({}, [
|
|
79
|
+
store2 = (0, store_1.createStoreWithoutState)({}, [persistenceMiddleware]);
|
|
79
80
|
}
|
|
80
81
|
// Init store for CSR to hydrate components
|
|
81
82
|
if (isBrowser) {
|
|
@@ -106,11 +107,14 @@ function ApiItem(props) {
|
|
|
106
107
|
securitySchemes: api?.securitySchemes,
|
|
107
108
|
options,
|
|
108
109
|
});
|
|
110
|
+
const storage = (0, storage_utils_1.createStorage)(
|
|
111
|
+
options?.authPersistence ?? "sessionStorage"
|
|
112
|
+
);
|
|
109
113
|
// TODO: determine way to rehydrate without flashing
|
|
110
114
|
// const acceptValue = window?.sessionStorage.getItem("accept");
|
|
111
115
|
// const contentTypeValue = window?.sessionStorage.getItem("contentType");
|
|
112
|
-
const server =
|
|
113
|
-
const serverObject = JSON.parse(server)
|
|
116
|
+
const server = storage.getItem("server");
|
|
117
|
+
const serverObject = server ? JSON.parse(server) : undefined;
|
|
114
118
|
store2 = (0, store_1.createStoreWithState)(
|
|
115
119
|
{
|
|
116
120
|
accept: {
|
|
@@ -122,7 +126,7 @@ function ApiItem(props) {
|
|
|
122
126
|
options: contentTypeArray,
|
|
123
127
|
},
|
|
124
128
|
server: {
|
|
125
|
-
value: serverObject
|
|
129
|
+
value: serverObject?.url ? serverObject : undefined,
|
|
126
130
|
options: servers,
|
|
127
131
|
},
|
|
128
132
|
response: { value: undefined },
|
|
@@ -130,7 +134,7 @@ function ApiItem(props) {
|
|
|
130
134
|
params,
|
|
131
135
|
auth,
|
|
132
136
|
},
|
|
133
|
-
[
|
|
137
|
+
[persistenceMiddleware]
|
|
134
138
|
);
|
|
135
139
|
}
|
|
136
140
|
if (api) {
|
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
declare const rootReducer: import("redux").Reducer<
|
|
2
|
-
accept:
|
|
3
|
-
contentType:
|
|
4
|
-
response:
|
|
5
|
-
server:
|
|
6
|
-
body:
|
|
7
|
-
params:
|
|
8
|
-
auth:
|
|
9
|
-
}
|
|
1
|
+
declare const rootReducer: import("redux").Reducer<{
|
|
2
|
+
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
3
|
+
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
4
|
+
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
5
|
+
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
6
|
+
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
7
|
+
params: import("@theme/ApiExplorer/ParamOptions/slice").State;
|
|
8
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
|
|
9
|
+
}, import("redux").UnknownAction, Partial<{
|
|
10
|
+
accept: import("@theme/ApiExplorer/Accept/slice").State | undefined;
|
|
11
|
+
contentType: import("@theme/ApiExplorer/ContentType/slice").State | undefined;
|
|
12
|
+
response: import("@theme/ApiExplorer/Response/slice").State | undefined;
|
|
13
|
+
server: import("@theme/ApiExplorer/Server/slice").State | undefined;
|
|
14
|
+
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody | undefined;
|
|
15
|
+
params: import("@theme/ApiExplorer/ParamOptions/slice").State | undefined;
|
|
16
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState | undefined;
|
|
17
|
+
}>>;
|
|
10
18
|
export type RootState = ReturnType<typeof rootReducer>;
|
|
11
|
-
export declare const createStoreWithState: (preloadedState: RootState, middlewares: any[]) => import("@reduxjs/toolkit
|
|
12
|
-
accept:
|
|
13
|
-
contentType:
|
|
14
|
-
response:
|
|
15
|
-
server:
|
|
16
|
-
body:
|
|
17
|
-
params:
|
|
18
|
-
auth:
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
export declare const createStoreWithState: (preloadedState: RootState, middlewares: any[]) => import("@reduxjs/toolkit").EnhancedStore<{
|
|
20
|
+
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
21
|
+
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
22
|
+
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
23
|
+
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
24
|
+
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
25
|
+
params: import("@theme/ApiExplorer/ParamOptions/slice").State;
|
|
26
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
|
|
27
|
+
}, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
28
|
+
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
29
|
+
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
30
|
+
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
31
|
+
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
32
|
+
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
33
|
+
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
34
|
+
params: import("@theme/ApiExplorer/ParamOptions/slice").State;
|
|
35
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
|
|
36
|
+
}, undefined, import("redux").UnknownAction>;
|
|
37
|
+
}>, import("redux").StoreEnhancer]>>;
|
|
38
|
+
export declare const createStoreWithoutState: (preloadedState: {}, middlewares: any[]) => import("@reduxjs/toolkit").EnhancedStore<{
|
|
39
|
+
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
40
|
+
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
41
|
+
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
42
|
+
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
43
|
+
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
44
|
+
params: import("@theme/ApiExplorer/ParamOptions/slice").State;
|
|
45
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
|
|
46
|
+
}, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
47
|
+
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
48
|
+
accept: import("@theme/ApiExplorer/Accept/slice").State;
|
|
49
|
+
contentType: import("@theme/ApiExplorer/ContentType/slice").State;
|
|
50
|
+
response: import("@theme/ApiExplorer/Response/slice").State;
|
|
51
|
+
server: import("@theme/ApiExplorer/Server/slice").State;
|
|
52
|
+
body: import("@theme/ApiExplorer/Body/slice").FormBody | import("@theme/ApiExplorer/Body/slice").RawBody | import("@theme/ApiExplorer/Body/slice").EmptyBody;
|
|
53
|
+
params: import("@theme/ApiExplorer/ParamOptions/slice").State;
|
|
54
|
+
auth: import("@theme/ApiExplorer/Authorization/slice").AuthState;
|
|
55
|
+
}, undefined, import("redux").UnknownAction>;
|
|
56
|
+
}>, import("redux").StoreEnhancer]>>;
|
|
45
57
|
export type AppDispatch = ReturnType<typeof createStoreWithState>["dispatch"];
|
|
46
58
|
export {};
|
|
@@ -70,8 +70,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
70
70
|
exports.default = ApiTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
72
|
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
73
74
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
75
|
const Heading_1 = __importDefault(require("@theme/Heading"));
|
|
76
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
75
77
|
const clsx_1 = __importDefault(require("clsx"));
|
|
76
78
|
function TabList({
|
|
77
79
|
className,
|
|
@@ -79,7 +81,10 @@ function TabList({
|
|
|
79
81
|
selectedValue,
|
|
80
82
|
selectValue,
|
|
81
83
|
tabValues,
|
|
82
|
-
label =
|
|
84
|
+
label = (0, Translate_1.translate)({
|
|
85
|
+
id: translationIds_1.OPENAPI_TABS.RESPONSES_LABEL,
|
|
86
|
+
message: "Responses",
|
|
87
|
+
}),
|
|
83
88
|
id = "responses",
|
|
84
89
|
}) {
|
|
85
90
|
const tabRefs = [];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ExampleObject } from "@theme/ParamsItem";
|
|
3
|
+
type ExampleType = string;
|
|
4
|
+
type ExamplesType = Record<string, ExampleObject> | string[];
|
|
5
|
+
/**
|
|
6
|
+
* Example Component Props
|
|
7
|
+
*/
|
|
8
|
+
type ExampleProps = {
|
|
9
|
+
example?: ExampleType;
|
|
10
|
+
examples?: ExamplesType;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Example Component
|
|
14
|
+
*/
|
|
15
|
+
export declare const Example: ({ example, examples }: ExampleProps) => React.JSX.Element | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Render string examples
|
|
18
|
+
*
|
|
19
|
+
* @param examples
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderStringArrayExamples(examples: string[]): React.JSX.Element | undefined;
|
|
23
|
+
export declare const renderExamplesRecord: (examples: Record<string, ExampleObject>) => React.JSX.Element | undefined;
|
|
24
|
+
export {};
|