docusaurus-theme-openapi-docs 0.0.0-1083 → 0.0.0-1085

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.
Files changed (29) hide show
  1. package/lib/theme/ApiExplorer/Authorization/slice.js +3 -1
  2. package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.d.ts +7 -0
  3. package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +126 -0
  4. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +9 -0
  5. package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +110 -0
  6. package/lib/theme/ApiExplorer/Body/index.js +42 -97
  7. package/lib/theme/ApiExplorer/Body/slice.d.ts +27 -2
  8. package/lib/theme/ApiExplorer/Body/slice.js +22 -2
  9. package/lib/theme/ApiExplorer/LiveEditor/index.js +2 -3
  10. package/lib/theme/ApiExplorer/buildPostmanRequest.js +23 -7
  11. package/lib/theme/ApiExplorer/{persistanceMiddleware.d.ts → persistenceMiddleware.d.ts} +3 -3
  12. package/lib/theme/ApiExplorer/{persistanceMiddleware.js → persistenceMiddleware.js} +16 -9
  13. package/lib/theme/ApiExplorer/storage-utils.d.ts +2 -2
  14. package/lib/theme/ApiExplorer/storage-utils.js +3 -3
  15. package/lib/theme/ApiItem/index.js +12 -8
  16. package/lib/types.d.ts +7 -1
  17. package/package.json +3 -3
  18. package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
  19. package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +77 -0
  20. package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +120 -0
  21. package/src/theme/ApiExplorer/Body/index.tsx +39 -104
  22. package/src/theme/ApiExplorer/Body/slice.ts +40 -1
  23. package/src/theme/ApiExplorer/LiveEditor/index.tsx +2 -3
  24. package/src/theme/ApiExplorer/buildPostmanRequest.ts +23 -7
  25. package/src/theme/ApiExplorer/{persistanceMiddleware.ts → persistenceMiddleware.ts} +20 -12
  26. package/src/theme/ApiExplorer/storage-utils.ts +4 -4
  27. package/src/theme/ApiItem/index.tsx +12 -7
  28. package/src/types.ts +7 -1
  29. package/tsconfig.tsbuildinfo +1 -1
@@ -40,7 +40,9 @@ const auth_types_1 = require("./auth-types");
40
40
  // BearerAuth -> { token: xxx }
41
41
  // BasicAuth -> { username: xxx, password: xxx }
42
42
  function createAuth({ security, securitySchemes, options: opts }) {
43
- const storage = (0, storage_utils_1.createStorage)("sessionStorage");
43
+ const storage = (0, storage_utils_1.createStorage)(
44
+ opts?.authPersistence ?? "sessionStorage"
45
+ );
44
46
  let data = {};
45
47
  let options = {};
46
48
  for (const option of security ?? []) {
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ interface FileArrayFormItemProps {
3
+ id: string;
4
+ description: string | undefined;
5
+ }
6
+ export default function FileArrayFormBodyItem({ id, description, }: FileArrayFormItemProps): React.JSX.Element;
7
+ export {};
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
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
+ })();
64
+ var __importDefault =
65
+ (this && this.__importDefault) ||
66
+ function (mod) {
67
+ return mod && mod.__esModule ? mod : { default: mod };
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.default = FileArrayFormBodyItem;
71
+ const react_1 = __importStar(require("react"));
72
+ const FormFileUpload_1 = __importDefault(
73
+ require("@theme/ApiExplorer/FormFileUpload")
74
+ );
75
+ const hooks_1 = require("@theme/ApiItem/hooks");
76
+ const slice_1 = require("../slice");
77
+ function FileArrayFormBodyItem({ id, description }) {
78
+ const dispatch = (0, hooks_1.useTypedDispatch)();
79
+ const [fileItems, setFileItems] = (0, react_1.useState)(
80
+ new Map([[0, undefined]])
81
+ );
82
+ const handleFileChange = (index, file) => {
83
+ const newItems = new Map(fileItems);
84
+ if (file === undefined) {
85
+ newItems.delete(index);
86
+ setFileItems(newItems);
87
+ dispatch(
88
+ (0, slice_1.setFileArrayFormBody)({
89
+ key: id,
90
+ value: [...newItems.values()].filter((item) => item !== undefined),
91
+ })
92
+ );
93
+ return;
94
+ }
95
+ let maxIndex = 0;
96
+ newItems.keys().forEach((item) => {
97
+ maxIndex = item > maxIndex ? item : maxIndex;
98
+ });
99
+ newItems.set(index, {
100
+ src: `/path/to/${file.name}`,
101
+ content: file,
102
+ });
103
+ newItems.set(index + 1, undefined);
104
+ setFileItems(newItems);
105
+ dispatch(
106
+ (0, slice_1.setFileArrayFormBody)({
107
+ key: id,
108
+ value: [...newItems.values()].filter((item) => item !== undefined),
109
+ })
110
+ );
111
+ };
112
+ return react_1.default.createElement(
113
+ "div",
114
+ null,
115
+ [...fileItems.keys()].map((index) =>
116
+ react_1.default.createElement(
117
+ "div",
118
+ { key: index },
119
+ react_1.default.createElement(FormFileUpload_1.default, {
120
+ placeholder: description || id,
121
+ onChange: (file) => handleFileChange(index, file),
122
+ })
123
+ )
124
+ )
125
+ );
126
+ }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { SchemaObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
3
+ interface FormBodyItemProps {
4
+ schemaObject: SchemaObject;
5
+ id: string;
6
+ schema: SchemaObject;
7
+ }
8
+ export default function FormBodyItem({ schemaObject, id, schema, }: FormBodyItemProps): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ var __importDefault =
9
+ (this && this.__importDefault) ||
10
+ function (mod) {
11
+ return mod && mod.__esModule ? mod : { default: mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.default = FormBodyItem;
15
+ const react_1 = __importDefault(require("react"));
16
+ const FormFileUpload_1 = __importDefault(
17
+ require("@theme/ApiExplorer/FormFileUpload")
18
+ );
19
+ const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
20
+ const FormTextInput_1 = __importDefault(
21
+ require("@theme/ApiExplorer/FormTextInput")
22
+ );
23
+ const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
24
+ const hooks_1 = require("@theme/ApiItem/hooks");
25
+ const slice_1 = require("../slice");
26
+ const FileArrayFormBodyItem_1 = __importDefault(
27
+ require("../FileArrayFormBodyItem")
28
+ );
29
+ function FormBodyItem({ schemaObject, id, schema }) {
30
+ const dispatch = (0, hooks_1.useTypedDispatch)();
31
+ if (
32
+ schemaObject.type === "array" &&
33
+ schemaObject.items?.format === "binary"
34
+ ) {
35
+ return react_1.default.createElement(FileArrayFormBodyItem_1.default, {
36
+ id: id,
37
+ description: schemaObject.description,
38
+ });
39
+ }
40
+ if (schemaObject.format === "binary") {
41
+ return react_1.default.createElement(FormFileUpload_1.default, {
42
+ placeholder: schemaObject.description || id,
43
+ onChange: (file) => {
44
+ if (file === undefined) {
45
+ dispatch((0, slice_1.clearFormBodyKey)(id));
46
+ return;
47
+ }
48
+ dispatch(
49
+ (0, slice_1.setFileFormBody)({
50
+ key: id,
51
+ value: {
52
+ src: `/path/to/${file.name}`,
53
+ content: file,
54
+ },
55
+ })
56
+ );
57
+ },
58
+ });
59
+ }
60
+ if (
61
+ schemaObject.type === "object" &&
62
+ (schemaObject.example || schemaObject.examples)
63
+ ) {
64
+ const objectExample = JSON.stringify(
65
+ schemaObject.example ?? schemaObject.examples[0],
66
+ null,
67
+ 2
68
+ );
69
+ return react_1.default.createElement(
70
+ LiveEditor_1.default,
71
+ {
72
+ action: (code) =>
73
+ dispatch((0, slice_1.setStringFormBody)({ key: id, value: code })),
74
+ },
75
+ objectExample
76
+ );
77
+ }
78
+ if (
79
+ schemaObject.enum &&
80
+ schemaObject.enum.every((value) => typeof value === "string")
81
+ ) {
82
+ return react_1.default.createElement(FormSelect_1.default, {
83
+ options: ["---", ...schemaObject.enum],
84
+ onChange: (e) => {
85
+ const val = e.target.value;
86
+ if (val === "---") {
87
+ dispatch((0, slice_1.clearFormBodyKey)(id));
88
+ } else {
89
+ dispatch(
90
+ (0, slice_1.setStringFormBody)({
91
+ key: id,
92
+ value: val,
93
+ })
94
+ );
95
+ }
96
+ },
97
+ });
98
+ }
99
+ // TODO: support all the other types.
100
+ return react_1.default.createElement(FormTextInput_1.default, {
101
+ paramName: id,
102
+ isRequired: Array.isArray(schema.required) && schema.required.includes(id),
103
+ placeholder: schemaObject.description || id,
104
+ onChange: (e) => {
105
+ dispatch(
106
+ (0, slice_1.setStringFormBody)({ key: id, value: e.target.value })
107
+ );
108
+ },
109
+ });
110
+ }
@@ -18,10 +18,6 @@ const FormFileUpload_1 = __importDefault(
18
18
  require("@theme/ApiExplorer/FormFileUpload")
19
19
  );
20
20
  const FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
21
- const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
22
- const FormTextInput_1 = __importDefault(
23
- require("@theme/ApiExplorer/FormTextInput")
24
- );
25
21
  const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
26
22
  const hooks_1 = require("@theme/ApiItem/hooks");
27
23
  const Markdown_1 = __importDefault(require("@theme/Markdown"));
@@ -30,6 +26,7 @@ const TabItem_1 = __importDefault(require("@theme/TabItem"));
30
26
  const translationIds_1 = require("@theme/translationIds");
31
27
  const xml_formatter_1 = __importDefault(require("xml-formatter"));
32
28
  const slice_1 = require("./slice");
29
+ const FormBodyItem_1 = __importDefault(require("./FormBodyItem"));
33
30
  function BodyWrap({
34
31
  requestBodyMetadata,
35
32
  jsonRequestBodyExample,
@@ -118,94 +115,22 @@ function Body({
118
115
  return react_1.default.createElement(
119
116
  FormItem_1.default,
120
117
  { className: "openapi-explorer__form-item-body-container" },
121
- react_1.default.createElement(
122
- "div",
123
- null,
124
- Object.entries(schema.properties ?? {}).map(([key, val]) => {
125
- if (val.format === "binary") {
126
- return react_1.default.createElement(
127
- FormItem_1.default,
128
- {
129
- key: key,
130
- label: key,
131
- required:
132
- Array.isArray(schema.required) &&
133
- schema.required.includes(key),
134
- },
135
- react_1.default.createElement(FormFileUpload_1.default, {
136
- placeholder: val.description || key,
137
- onChange: (file) => {
138
- if (file === undefined) {
139
- dispatch((0, slice_1.clearFormBodyKey)(key));
140
- return;
141
- }
142
- dispatch(
143
- (0, slice_1.setFileFormBody)({
144
- key: key,
145
- value: {
146
- src: `/path/to/${file.name}`,
147
- content: file,
148
- },
149
- })
150
- );
151
- },
152
- })
153
- );
154
- }
155
- if (val.enum) {
156
- return react_1.default.createElement(
157
- FormItem_1.default,
158
- {
159
- key: key,
160
- label: key,
161
- required:
162
- Array.isArray(schema.required) &&
163
- schema.required.includes(key),
164
- },
165
- react_1.default.createElement(FormSelect_1.default, {
166
- options: ["---", ...val.enum],
167
- onChange: (e) => {
168
- const val = e.target.value;
169
- if (val === "---") {
170
- dispatch((0, slice_1.clearFormBodyKey)(key));
171
- } else {
172
- dispatch(
173
- (0, slice_1.setStringFormBody)({
174
- key: key,
175
- value: val,
176
- })
177
- );
178
- }
179
- },
180
- })
181
- );
182
- }
183
- // TODO: support all the other types.
184
- return react_1.default.createElement(
185
- FormItem_1.default,
186
- {
187
- key: key,
188
- label: key,
189
- required:
190
- Array.isArray(schema.required) && schema.required.includes(key),
191
- },
192
- react_1.default.createElement(FormTextInput_1.default, {
193
- paramName: key,
194
- isRequired:
195
- Array.isArray(schema.required) && schema.required.includes(key),
196
- placeholder: val.description || key,
197
- onChange: (e) => {
198
- dispatch(
199
- (0, slice_1.setStringFormBody)({
200
- key: key,
201
- value: e.target.value,
202
- })
203
- );
204
- },
205
- })
206
- );
207
- })
208
- )
118
+ Object.entries(schema.properties ?? {}).map(([key, val]) => {
119
+ return react_1.default.createElement(
120
+ FormItem_1.default,
121
+ {
122
+ key: key,
123
+ label: key,
124
+ required:
125
+ Array.isArray(schema.required) && schema.required.includes(key),
126
+ },
127
+ react_1.default.createElement(FormBodyItem_1.default, {
128
+ schemaObject: val,
129
+ id: key,
130
+ schema: schema,
131
+ })
132
+ );
133
+ })
209
134
  );
210
135
  }
211
136
  let language = "plaintext";
@@ -343,7 +268,11 @@ function Body({
343
268
  },
344
269
  react_1.default.createElement(
345
270
  LiveEditor_1.default,
346
- { action: dispatch, language: language, required: required },
271
+ {
272
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
273
+ language: language,
274
+ required: required,
275
+ },
347
276
  defaultBody
348
277
  )
349
278
  ),
@@ -359,7 +288,11 @@ function Body({
359
288
  exampleBody &&
360
289
  react_1.default.createElement(
361
290
  LiveEditor_1.default,
362
- { action: dispatch, language: language, required: required },
291
+ {
292
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
293
+ language: language,
294
+ required: required,
295
+ },
363
296
  exampleBody
364
297
  )
365
298
  )
@@ -385,7 +318,11 @@ function Body({
385
318
  },
386
319
  react_1.default.createElement(
387
320
  LiveEditor_1.default,
388
- { action: dispatch, language: language, required: required },
321
+ {
322
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
323
+ language: language,
324
+ required: required,
325
+ },
389
326
  defaultBody
390
327
  )
391
328
  ),
@@ -408,7 +345,11 @@ function Body({
408
345
  example.body &&
409
346
  react_1.default.createElement(
410
347
  LiveEditor_1.default,
411
- { action: dispatch, language: language },
348
+ {
349
+ action: (code) =>
350
+ dispatch((0, slice_1.setStringRawBody)(code)),
351
+ language: language,
352
+ },
412
353
  example.body
413
354
  )
414
355
  )
@@ -422,7 +363,11 @@ function Body({
422
363
  null,
423
364
  react_1.default.createElement(
424
365
  LiveEditor_1.default,
425
- { action: dispatch, language: language, required: required },
366
+ {
367
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
368
+ language: language,
369
+ required: required,
370
+ },
426
371
  defaultBody
427
372
  )
428
373
  );
@@ -6,11 +6,18 @@ export interface FileContent {
6
6
  content: Blob;
7
7
  };
8
8
  }
9
+ export interface FileArrayContent {
10
+ type: "file[]";
11
+ value: {
12
+ src: string;
13
+ content: Blob;
14
+ }[];
15
+ }
9
16
  export interface StringContent {
10
17
  type: "string";
11
18
  value?: string;
12
19
  }
13
- export type Content = FileContent | StringContent | undefined;
20
+ export type Content = FileContent | FileArrayContent | StringContent | undefined;
14
21
  export interface FormBody {
15
22
  type: "form";
16
23
  content: {
@@ -67,6 +74,21 @@ export declare const slice: import("@reduxjs/toolkit").Slice<FormBody | RawBody
67
74
  };
68
75
  };
69
76
  };
77
+ setFileArrayFormBody: (state: import("immer").WritableDraft<FormBody> | import("immer").WritableDraft<RawBody> | import("immer").WritableDraft<EmptyBody>, action: PayloadAction<{
78
+ key: string;
79
+ value: FileArrayContent["value"];
80
+ }>) => import("immer").WritableDraft<FormBody> | {
81
+ type: "form";
82
+ content: {
83
+ [x: string]: {
84
+ type: "file[]";
85
+ value: {
86
+ src: string;
87
+ content: Blob;
88
+ }[];
89
+ };
90
+ };
91
+ };
70
92
  }, "body", "body", import("@reduxjs/toolkit").SliceSelectors<FormBody | RawBody | EmptyBody>>;
71
93
  export declare const clearRawBody: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"body/clearRawBody">, setStringRawBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "body/setStringRawBody">, setFileRawBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
72
94
  src: string;
@@ -77,6 +99,9 @@ export declare const clearRawBody: import("@reduxjs/toolkit").ActionCreatorWitho
77
99
  }, "body/setStringFormBody">, setFileFormBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
78
100
  key: string;
79
101
  value: FileContent["value"];
80
- }, "body/setFileFormBody">;
102
+ }, "body/setFileFormBody">, setFileArrayFormBody: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
103
+ key: string;
104
+ value: FileArrayContent["value"];
105
+ }, "body/setFileArrayFormBody">;
81
106
  declare const _default: import("redux").Reducer<FormBody | RawBody | EmptyBody>;
82
107
  export default _default;
@@ -7,7 +7,8 @@
7
7
  * ========================================================================== */
8
8
  var _a;
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.setFileFormBody =
10
+ exports.setFileArrayFormBody =
11
+ exports.setFileFormBody =
11
12
  exports.setStringFormBody =
12
13
  exports.clearFormBodyKey =
13
14
  exports.setFileRawBody =
@@ -85,6 +86,24 @@ exports.slice = (0, toolkit_1.createSlice)({
85
86
  };
86
87
  return state;
87
88
  },
89
+ setFileArrayFormBody: (state, action) => {
90
+ if (state?.type !== "form") {
91
+ return {
92
+ type: "form",
93
+ content: {
94
+ [action.payload.key]: {
95
+ type: "file[]",
96
+ value: action.payload.value,
97
+ },
98
+ },
99
+ };
100
+ }
101
+ state.content[action.payload.key] = {
102
+ type: "file[]",
103
+ value: action.payload.value,
104
+ };
105
+ return state;
106
+ },
88
107
  },
89
108
  });
90
109
  ((_a = exports.slice.actions),
@@ -93,5 +112,6 @@ exports.slice = (0, toolkit_1.createSlice)({
93
112
  (exports.setFileRawBody = _a.setFileRawBody),
94
113
  (exports.clearFormBodyKey = _a.clearFormBodyKey),
95
114
  (exports.setStringFormBody = _a.setStringFormBody),
96
- (exports.setFileFormBody = _a.setFileFormBody));
115
+ (exports.setFileFormBody = _a.setFileFormBody),
116
+ (exports.setFileArrayFormBody = _a.setFileArrayFormBody));
97
117
  exports.default = exports.slice.reducer;
@@ -72,7 +72,6 @@ const theme_common_1 = require("@docusaurus/theme-common");
72
72
  const Translate_1 = require("@docusaurus/Translate");
73
73
  const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
74
74
  const error_message_1 = require("@hookform/error-message");
75
- const slice_1 = require("@theme/ApiExplorer/Body/slice");
76
75
  const translationIds_1 = require("@theme/translationIds");
77
76
  const clsx_1 = __importDefault(require("clsx"));
78
77
  const react_hook_form_1 = require("react-hook-form");
@@ -112,8 +111,8 @@ function App({
112
111
  const prismTheme = (0, theme_common_1.usePrismTheme)();
113
112
  const [code, setCode] = react_1.default.useState(children.replace(/\n$/, ""));
114
113
  (0, react_1.useEffect)(() => {
115
- action((0, slice_1.setStringRawBody)(code));
116
- }, [action, code]);
114
+ action(code);
115
+ }, [code]);
117
116
  const {
118
117
  control,
119
118
  formState: { errors },
@@ -331,7 +331,11 @@ function setBody(clonedPostman, body) {
331
331
  switch (clonedPostman.body.mode) {
332
332
  case "raw": {
333
333
  // check file even though it should already be set from above
334
- if (body.type !== "raw" || body.content?.type === "file") {
334
+ if (
335
+ body.type !== "raw" ||
336
+ body.content?.type === "file" ||
337
+ body.content?.type === "file[]"
338
+ ) {
335
339
  clonedPostman.body = undefined;
336
340
  return;
337
341
  }
@@ -346,15 +350,23 @@ function setBody(clonedPostman, body) {
346
350
  clonedPostman.body.raw = `${body.content?.value}`;
347
351
  return;
348
352
  }
349
- const params = Object.entries(body.content)
353
+ const params = [];
354
+ Object.entries(body.content)
350
355
  .filter((entry) => !!entry[1])
351
- .map(([key, content]) => {
356
+ .forEach(([key, content]) => {
352
357
  if (content.type === "file") {
353
- return new sdk.FormParam({ key: key, ...content });
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 }));
354
365
  }
355
- return new sdk.FormParam({ key: key, value: content.value });
356
366
  });
357
- clonedPostman.body.formdata?.assimilate(params, false);
367
+ params.forEach((param) => {
368
+ clonedPostman.body?.formdata?.add(param);
369
+ });
358
370
  return;
359
371
  }
360
372
  case "urlencoded": {
@@ -368,7 +380,11 @@ function setBody(clonedPostman, body) {
368
380
  const params = Object.entries(body.content)
369
381
  .filter((entry) => !!entry[1])
370
382
  .map(([key, content]) => {
371
- if (content.type !== "file" && content.value) {
383
+ if (
384
+ content.type !== "file" &&
385
+ content.type !== "file[]" &&
386
+ content.value
387
+ ) {
372
388
  return new sdk.QueryParam({ key: key, value: content.value });
373
389
  }
374
390
  return undefined;
@@ -1,6 +1,6 @@
1
- import { Middleware } from "@reduxjs/toolkit";
2
- import { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
3
- export declare function createPersistanceMiddleware(options: ThemeConfig["api"]): Middleware<{}, {
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
4
  accept: import("./Accept/slice").State;
5
5
  contentType: import("./ContentType/slice").State;
6
6
  response: import("./Response/slice").State;