docusaurus-theme-openapi-docs 4.4.0 → 4.5.1

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 (45) hide show
  1. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +3 -3
  2. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +5 -1
  3. package/lib/theme/ApiExplorer/Authorization/slice.js +2 -2
  4. package/lib/theme/ApiExplorer/Body/slice.js +2 -2
  5. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +3 -3
  6. package/lib/theme/ApiExplorer/Request/index.js +2 -2
  7. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +1 -1
  8. package/lib/theme/ApiExplorer/Request/makeRequest.js +3 -2
  9. package/lib/theme/ApiExplorer/Response/slice.js +2 -2
  10. package/lib/theme/ApiExplorer/Server/slice.js +2 -2
  11. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
  12. package/lib/theme/ApiExplorer/buildPostmanRequest.js +119 -46
  13. package/lib/theme/ApiExplorer/index.js +64 -2
  14. package/lib/theme/CodeSamples/_CodeSamples.scss +3 -0
  15. package/lib/theme/CodeSamples/index.d.ts +8 -0
  16. package/lib/theme/{ResponseSamples → CodeSamples}/index.js +4 -4
  17. package/lib/theme/ParamsItem/index.d.ts +1 -4
  18. package/lib/theme/ResponseExamples/index.js +9 -9
  19. package/lib/theme/Schema/index.js +39 -97
  20. package/lib/theme/SchemaItem/index.js +34 -0
  21. package/lib/theme/styles.scss +1 -1
  22. package/lib/types.d.ts +5 -116
  23. package/package.json +5 -3
  24. package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +3 -3
  25. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.tsx +5 -1
  26. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +3 -3
  27. package/src/theme/ApiExplorer/Request/index.tsx +2 -2
  28. package/src/theme/ApiExplorer/Request/makeRequest.ts +4 -3
  29. package/src/theme/ApiExplorer/buildPostmanRequest.ts +48 -18
  30. package/src/theme/ApiExplorer/index.tsx +8 -2
  31. package/src/theme/CodeSamples/_CodeSamples.scss +3 -0
  32. package/src/theme/{ResponseSamples → CodeSamples}/index.tsx +5 -10
  33. package/src/theme/ParamsItem/index.tsx +1 -5
  34. package/src/theme/ResponseExamples/index.tsx +6 -9
  35. package/src/theme/Schema/index.tsx +47 -78
  36. package/src/theme/SchemaItem/index.tsx +27 -0
  37. package/src/theme/styles.scss +1 -1
  38. package/src/types.ts +5 -115
  39. package/tsconfig.tsbuildinfo +1 -1
  40. package/lib/theme/ResponseSamples/_ResponseSamples.scss +0 -3
  41. package/lib/theme/ResponseSamples/index.d.ts +0 -8
  42. package/src/theme/ApiExplorer/postman-collection.d.ts +0 -10
  43. package/src/theme/ApiExplorer/react-modal.d.ts +0 -8
  44. package/src/theme/ResponseSamples/_ResponseSamples.scss +0 -3
  45. package/src/theme-translations.d.ts +0 -9
@@ -116,7 +116,7 @@ function CodeBlockString({
116
116
  getLineProps: getLineProps,
117
117
  getTokenProps: getTokenProps,
118
118
  classNames: lineClassNames[i],
119
- showLineNumbers: showLineNumbers,
119
+ showLineNumbers: !!showLineNumbers,
120
120
  })
121
121
  )
122
122
  )
@@ -142,9 +142,9 @@ function CodeBlockString({
142
142
  ),
143
143
  code: code,
144
144
  language: language ?? "text",
145
- showLineNumbers: showLineNumbers,
145
+ showLineNumbers: !!showLineNumbers,
146
146
  blockClassName: blockClassName,
147
- title: title,
147
+ title: typeof title === "string" ? title : undefined,
148
148
  lineClassNames: lineClassNames,
149
149
  })
150
150
  )
@@ -1,3 +1,7 @@
1
1
  import React from "react";
2
- import { CopyButtonProps } from "@docusaurus/theme-common/internal";
2
+ interface CopyButtonProps {
3
+ code: string;
4
+ className?: string;
5
+ }
3
6
  export default function CopyButton({ code, className, }: CopyButtonProps): React.JSX.Element;
7
+ export {};
@@ -96,7 +96,7 @@ exports.slice = (0, toolkit_1.createSlice)({
96
96
  },
97
97
  },
98
98
  });
99
- (_a = exports.slice.actions),
99
+ ((_a = exports.slice.actions),
100
100
  (exports.setAuthData = _a.setAuthData),
101
- (exports.setSelectedAuth = _a.setSelectedAuth);
101
+ (exports.setSelectedAuth = _a.setSelectedAuth));
102
102
  exports.default = exports.slice.reducer;
@@ -87,11 +87,11 @@ exports.slice = (0, toolkit_1.createSlice)({
87
87
  },
88
88
  },
89
89
  });
90
- (_a = exports.slice.actions),
90
+ ((_a = exports.slice.actions),
91
91
  (exports.clearRawBody = _a.clearRawBody),
92
92
  (exports.setStringRawBody = _a.setStringRawBody),
93
93
  (exports.setFileRawBody = _a.setFileRawBody),
94
94
  (exports.clearFormBodyKey = _a.clearFormBodyKey),
95
95
  (exports.setStringFormBody = _a.setStringFormBody),
96
- (exports.setFileFormBody = _a.setFileFormBody);
96
+ (exports.setFileFormBody = _a.setFileFormBody));
97
97
  exports.default = exports.slice.reducer;
@@ -1,10 +1,10 @@
1
- import { type JSX } from "react";
2
- import sdk from "postman-collection";
1
+ import React from "react";
2
+ import * as sdk from "postman-collection";
3
3
  import { CodeSample, Language } from "./code-snippets-types";
4
4
  export declare const languageSet: Language[];
5
5
  export interface Props {
6
6
  postman: sdk.Request;
7
7
  codeSamples: CodeSample[];
8
8
  }
9
- declare function CodeSnippets({ postman, codeSamples }: Props): JSX.Element | null;
9
+ declare function CodeSnippets({ postman, codeSamples }: Props): React.JSX.Element | null;
10
10
  export default CodeSnippets;
@@ -87,11 +87,11 @@ const ParamOptions_1 = __importDefault(
87
87
  const slice_1 = require("@theme/ApiExplorer/Response/slice");
88
88
  const Server_1 = __importDefault(require("@theme/ApiExplorer/Server"));
89
89
  const hooks_1 = require("@theme/ApiItem/hooks");
90
- const postman_collection_1 = __importDefault(require("postman-collection"));
90
+ const sdk = __importStar(require("postman-collection"));
91
91
  const react_hook_form_1 = require("react-hook-form");
92
92
  const makeRequest_1 = __importDefault(require("./makeRequest"));
93
93
  function Request({ item }) {
94
- const postman = new postman_collection_1.default.Request(item.postman);
94
+ const postman = new sdk.Request(item.postman);
95
95
  const metadata = (0, client_1.useDoc)();
96
96
  const { proxy, hide_send_button: hideSendButton } = metadata.frontMatter;
97
97
  const pathParams = (0, hooks_1.useTypedSelector)(
@@ -1,4 +1,4 @@
1
1
  import { Body } from "@theme/ApiExplorer/Body/slice";
2
- import sdk from "postman-collection";
2
+ import * as sdk from "postman-collection";
3
3
  declare function makeRequest(request: sdk.Request, proxy: string | undefined, _body: Body): Promise<any>;
4
4
  export default makeRequest;
@@ -136,8 +136,9 @@ async function makeRequest(request, proxy, _body) {
136
136
  // The Content-Type header will be set automatically based on the type of body.
137
137
  myHeaders.delete("Content-Type");
138
138
  myBody = new FormData();
139
- if (Array.isArray(request.body.formdata.members)) {
140
- for (const data of request.body.formdata.members) {
139
+ const members = request.body?.formdata?.members;
140
+ if (Array.isArray(members)) {
141
+ for (const data of members) {
141
142
  if (data.key && data.value.content) {
142
143
  myBody.append(data.key, data.value.content);
143
144
  }
@@ -41,11 +41,11 @@ exports.slice = (0, toolkit_1.createSlice)({
41
41
  },
42
42
  },
43
43
  });
44
- (_a = exports.slice.actions),
44
+ ((_a = exports.slice.actions),
45
45
  (exports.setResponse = _a.setResponse),
46
46
  (exports.clearResponse = _a.clearResponse),
47
47
  (exports.setCode = _a.setCode),
48
48
  (exports.clearCode = _a.clearCode),
49
49
  (exports.setHeaders = _a.setHeaders),
50
- (exports.clearHeaders = _a.clearHeaders);
50
+ (exports.clearHeaders = _a.clearHeaders));
51
51
  exports.default = exports.slice.reducer;
@@ -27,7 +27,7 @@ exports.slice = (0, toolkit_1.createSlice)({
27
27
  },
28
28
  },
29
29
  });
30
- (_a = exports.slice.actions),
30
+ ((_a = exports.slice.actions),
31
31
  (exports.setServer = _a.setServer),
32
- (exports.setServerVariable = _a.setServerVariable);
32
+ (exports.setServerVariable = _a.setServerVariable));
33
33
  exports.default = exports.slice.reducer;
@@ -1,7 +1,7 @@
1
1
  import { AuthState } from "@theme/ApiExplorer/Authorization/slice";
2
2
  import { Body } from "@theme/ApiExplorer/Body/slice";
3
3
  import { ParameterObject, ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
4
- import sdk from "postman-collection";
4
+ import * as sdk from "postman-collection";
5
5
  type Param = {
6
6
  value?: string | string[];
7
7
  } & ParameterObject;
@@ -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) {
@@ -12,7 +68,7 @@ var __importDefault =
12
68
  };
13
69
  Object.defineProperty(exports, "__esModule", { value: true });
14
70
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
15
- const postman_collection_1 = __importDefault(require("postman-collection"));
71
+ const sdk = __importStar(require("postman-collection"));
16
72
  function setQueryParams(postman, queryParams) {
17
73
  postman.url.query.clear();
18
74
  const qp = queryParams
@@ -23,25 +79,25 @@ function setQueryParams(postman, queryParams) {
23
79
  // Handle array values
24
80
  if (Array.isArray(param.value)) {
25
81
  if (param.style === "spaceDelimited") {
26
- return new postman_collection_1.default.QueryParam({
82
+ return new sdk.QueryParam({
27
83
  key: param.name,
28
84
  value: param.value.join(" "),
29
85
  });
30
86
  } else if (param.style === "pipeDelimited") {
31
- return new postman_collection_1.default.QueryParam({
87
+ return new sdk.QueryParam({
32
88
  key: param.name,
33
89
  value: param.value.join("|"),
34
90
  });
35
91
  } else if (param.explode) {
36
92
  return param.value.map(
37
93
  (val) =>
38
- new postman_collection_1.default.QueryParam({
94
+ new sdk.QueryParam({
39
95
  key: param.name,
40
96
  value: val,
41
97
  })
42
98
  );
43
99
  } else {
44
- return new postman_collection_1.default.QueryParam({
100
+ return new sdk.QueryParam({
45
101
  key: param.name,
46
102
  value: param.value.join(","),
47
103
  });
@@ -61,21 +117,21 @@ function setQueryParams(postman, queryParams) {
61
117
  if (param.style === "deepObject") {
62
118
  return Object.entries(jsonResult).map(
63
119
  ([key, val]) =>
64
- new postman_collection_1.default.QueryParam({
120
+ new sdk.QueryParam({
65
121
  key: `${param.name}[${key}]`,
66
- value: val,
122
+ value: String(val),
67
123
  })
68
124
  );
69
125
  } else if (param.explode) {
70
126
  return Object.entries(jsonResult).map(
71
127
  ([key, val]) =>
72
- new postman_collection_1.default.QueryParam({
128
+ new sdk.QueryParam({
73
129
  key: key,
74
- value: val,
130
+ value: String(val),
75
131
  })
76
132
  );
77
133
  } else {
78
- return new postman_collection_1.default.QueryParam({
134
+ return new sdk.QueryParam({
79
135
  key: param.name,
80
136
  value: Object.entries(jsonResult)
81
137
  .map(([key, val]) => `${key},${val}`)
@@ -85,7 +141,7 @@ function setQueryParams(postman, queryParams) {
85
141
  }
86
142
  // Handle boolean values
87
143
  if (typeof decodedValue === "boolean") {
88
- return new postman_collection_1.default.QueryParam({
144
+ return new sdk.QueryParam({
89
145
  key: param.name,
90
146
  value: decodedValue ? "true" : "false",
91
147
  });
@@ -93,14 +149,14 @@ function setQueryParams(postman, queryParams) {
93
149
  // Parameter allows empty value: "/hello?extended"
94
150
  if (param.allowEmptyValue) {
95
151
  if (decodedValue === "true") {
96
- return new postman_collection_1.default.QueryParam({
152
+ return new sdk.QueryParam({
97
153
  key: param.name,
98
154
  value: null,
99
155
  });
100
156
  }
101
157
  return undefined;
102
158
  }
103
- return new postman_collection_1.default.QueryParam({
159
+ return new sdk.QueryParam({
104
160
  key: param.name,
105
161
  value: param.value,
106
162
  });
@@ -127,7 +183,7 @@ function setPathParams(postman, pathParams) {
127
183
  } else {
128
184
  serializedValue = param.value.join(",");
129
185
  }
130
- return new postman_collection_1.default.Variable({
186
+ return new sdk.Variable({
131
187
  key: param.name,
132
188
  value: serializedValue,
133
189
  });
@@ -154,12 +210,15 @@ function setPathParams(postman, pathParams) {
154
210
  } else {
155
211
  serializedValue = decodedValue || `:${param.name}`;
156
212
  }
157
- return new postman_collection_1.default.Variable({
213
+ return new sdk.Variable({
158
214
  key: param.name,
159
215
  value: serializedValue,
160
216
  });
161
217
  });
162
- postman.url.variables.assimilate(source, false);
218
+ postman.url.variables.assimilate(
219
+ source.filter((v) => v !== undefined),
220
+ false
221
+ );
163
222
  }
164
223
  function buildCookie(cookieParams) {
165
224
  const cookies = cookieParams
@@ -181,26 +240,32 @@ function buildCookie(cookieParams) {
181
240
  // Serialize each key-value pair as a separate cookie
182
241
  return Object.entries(jsonResult).map(
183
242
  ([key, val]) =>
184
- new postman_collection_1.default.Cookie({
243
+ new sdk.Cookie({
185
244
  key: key,
186
- value: val,
245
+ value: String(val),
246
+ domain: "",
247
+ path: "",
187
248
  })
188
249
  );
189
250
  } else {
190
251
  // Serialize the object as a single cookie with key-value pairs joined by commas
191
- return new postman_collection_1.default.Cookie({
252
+ return new sdk.Cookie({
192
253
  key: param.name,
193
254
  value: Object.entries(jsonResult)
194
255
  .map(([key, val]) => `${key},${val}`)
195
256
  .join(","),
257
+ domain: "",
258
+ path: "",
196
259
  });
197
260
  }
198
261
  }
199
262
  } else {
200
263
  // Handle scalar values
201
- return new postman_collection_1.default.Cookie({
264
+ return new sdk.Cookie({
202
265
  key: param.name,
203
- value: param.value,
266
+ value: String(param.value),
267
+ domain: "",
268
+ path: "",
204
269
  });
205
270
  }
206
271
  }
@@ -208,7 +273,7 @@ function buildCookie(cookieParams) {
208
273
  })
209
274
  .flat() // Flatten the array in case of nested arrays from map
210
275
  .filter((item) => item !== undefined);
211
- const list = new postman_collection_1.default.CookieList(null, cookies);
276
+ const list = new sdk.CookieList(null, cookies);
212
277
  return list.toString();
213
278
  }
214
279
  function setHeaders(postman, contentType, accept, cookie, headerParams, other) {
@@ -312,15 +377,9 @@ function setBody(clonedPostman, body) {
312
377
  .filter((entry) => !!entry[1])
313
378
  .map(([key, content]) => {
314
379
  if (content.type === "file") {
315
- return new postman_collection_1.default.FormParam({
316
- key: key,
317
- ...content,
318
- });
380
+ return new sdk.FormParam({ key: key, ...content });
319
381
  }
320
- return new postman_collection_1.default.FormParam({
321
- key: key,
322
- value: content.value,
323
- });
382
+ return new sdk.FormParam({ key: key, value: content.value });
324
383
  });
325
384
  clonedPostman.body.formdata?.assimilate(params, false);
326
385
  return;
@@ -337,10 +396,7 @@ function setBody(clonedPostman, body) {
337
396
  .filter((entry) => !!entry[1])
338
397
  .map(([key, content]) => {
339
398
  if (content.type !== "file" && content.value) {
340
- return new postman_collection_1.default.QueryParam({
341
- key: key,
342
- value: content.value,
343
- });
399
+ return new sdk.QueryParam({ key: key, value: content.value });
344
400
  }
345
401
  return undefined;
346
402
  })
@@ -379,9 +435,8 @@ function buildPostmanRequest(
379
435
  }
380
436
  clonedPostman.url.host = [url];
381
437
  }
382
- setQueryParams(clonedPostman, queryParams);
383
- setPathParams(clonedPostman, pathParams);
384
- const cookie = buildCookie(cookieParams);
438
+ const enhancedQueryParams = [...queryParams];
439
+ const enhancedCookieParams = [...cookieParams];
385
440
  let otherHeaders = [];
386
441
  let selectedAuth = [];
387
442
  if (auth.selected !== undefined) {
@@ -434,23 +489,41 @@ function buildPostmanRequest(
434
489
  });
435
490
  continue;
436
491
  }
437
- // API Key
492
+ // API Key in header
438
493
  if (a.type === "apiKey" && a.in === "header") {
439
494
  const { apiKey } = auth.data[a.key];
440
- if (apiKey === undefined) {
441
- otherHeaders.push({
442
- key: a.name,
443
- value: `<${a.name ?? a.type}>`,
444
- });
445
- continue;
446
- }
447
495
  otherHeaders.push({
448
496
  key: a.name,
449
- value: apiKey,
497
+ value: apiKey || `<${a.name ?? a.type}>`,
498
+ });
499
+ continue;
500
+ }
501
+ // API Key in query
502
+ if (a.type === "apiKey" && a.in === "query") {
503
+ const { apiKey } = auth.data[a.key];
504
+ enhancedQueryParams.push({
505
+ name: a.name,
506
+ in: "query",
507
+ value: apiKey || `<${a.name ?? a.type}>`,
508
+ });
509
+ continue;
510
+ }
511
+ // API Key in cookie
512
+ if (a.type === "apiKey" && a.in === "cookie") {
513
+ const { apiKey } = auth.data[a.key];
514
+ enhancedCookieParams.push({
515
+ name: a.name,
516
+ in: "cookie",
517
+ value: apiKey || `<${a.name ?? a.type}>`,
450
518
  });
451
519
  continue;
452
520
  }
453
521
  }
522
+ // Use the enhanced params that might include API keys
523
+ setQueryParams(clonedPostman, enhancedQueryParams);
524
+ setPathParams(clonedPostman, pathParams);
525
+ // Use enhanced cookie params that might include API keys
526
+ const cookie = buildCookie(enhancedCookieParams);
454
527
  setHeaders(
455
528
  clonedPostman,
456
529
  contentType,
@@ -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) {
@@ -20,9 +76,15 @@ const Response_1 = __importDefault(require("@theme/ApiExplorer/Response"));
20
76
  const SecuritySchemes_1 = __importDefault(
21
77
  require("@theme/ApiExplorer/SecuritySchemes")
22
78
  );
23
- const postman_collection_1 = __importDefault(require("postman-collection"));
79
+ const sdk = __importStar(require("postman-collection"));
24
80
  function ApiExplorer({ item, infoPath }) {
25
- const postman = new postman_collection_1.default.Request(item.postman);
81
+ const postman = new sdk.Request(
82
+ item.postman
83
+ ? sdk.Request.isRequest(item.postman)
84
+ ? item.postman.toJSON()
85
+ : item.postman
86
+ : {}
87
+ );
26
88
  return react_1.default.createElement(
27
89
  react_1.default.Fragment,
28
90
  null,
@@ -0,0 +1,3 @@
1
+ .openapi-code__code-samples-container {
2
+ margin-top: 2rem;
3
+ }
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { Language } from "prism-react-renderer";
3
+ export interface Props {
4
+ readonly example: string;
5
+ readonly language: Language;
6
+ }
7
+ declare function CodeSamples({ example, language }: Props): React.JSX.Element;
8
+ export default CodeSamples;
@@ -13,15 +13,15 @@ var __importDefault =
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  const react_1 = __importDefault(require("react"));
15
15
  const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
16
- function ResponseSamples({ responseExample, language }) {
16
+ function CodeSamples({ example, language }) {
17
17
  return react_1.default.createElement(
18
18
  "div",
19
- { className: "openapi-code__response-samples-container" },
19
+ { className: "openapi-code__code-samples-container" },
20
20
  react_1.default.createElement(
21
21
  CodeBlock_1.default,
22
22
  { language: language ? language : "json" },
23
- responseExample
23
+ example
24
24
  )
25
25
  );
26
26
  }
27
- exports.default = ResponseSamples;
27
+ exports.default = CodeSamples;
@@ -1,7 +1,4 @@
1
1
  import React from "react";
2
- interface Map<T> {
3
- [key: string]: T;
4
- }
5
2
  export interface ExampleObject {
6
3
  summary?: string;
7
4
  description?: string;
@@ -13,7 +10,7 @@ export interface Props {
13
10
  param: {
14
11
  description: string;
15
12
  example: any;
16
- examples: Map<ExampleObject>;
13
+ examples: Record<string, ExampleObject>;
17
14
  name: string;
18
15
  required: boolean;
19
16
  deprecated: boolean;
@@ -17,8 +17,8 @@ exports.ExampleFromSchema =
17
17
  void 0;
18
18
  exports.json2xml = json2xml;
19
19
  const react_1 = __importDefault(require("react"));
20
+ const CodeSamples_1 = __importDefault(require("@theme/CodeSamples"));
20
21
  const Markdown_1 = __importDefault(require("@theme/Markdown"));
21
- const ResponseSamples_1 = __importDefault(require("@theme/ResponseSamples"));
22
22
  const TabItem_1 = __importDefault(require("@theme/TabItem"));
23
23
  const createResponseExample_1 = require("docusaurus-plugin-openapi-docs/lib/openapi/createResponseExample");
24
24
  const xml_formatter_1 = __importDefault(require("xml-formatter"));
@@ -80,8 +80,8 @@ const ResponseExamples = ({ responseExamples, mimeType }) => {
80
80
  { className: "openapi-example__summary" },
81
81
  exampleValue.summary
82
82
  ),
83
- react_1.default.createElement(ResponseSamples_1.default, {
84
- responseExample: responseExample,
83
+ react_1.default.createElement(CodeSamples_1.default, {
84
+ example: responseExample,
85
85
  language: language,
86
86
  })
87
87
  )
@@ -114,8 +114,8 @@ const ResponseExample = ({ responseExample, mimeType }) => {
114
114
  { className: "openapi-example__summary" },
115
115
  responseExample.summary
116
116
  ),
117
- react_1.default.createElement(ResponseSamples_1.default, {
118
- responseExample: exampleContent,
117
+ react_1.default.createElement(CodeSamples_1.default, {
118
+ example: exampleContent,
119
119
  language: language,
120
120
  })
121
121
  )
@@ -164,8 +164,8 @@ const ExampleFromSchema = ({ schema, mimeType }) => {
164
164
  react_1.default.createElement(
165
165
  TabItem_1.default,
166
166
  { label: "Example (auto)", value: "Example (auto)" },
167
- react_1.default.createElement(ResponseSamples_1.default, {
168
- responseExample: xmlExample,
167
+ react_1.default.createElement(CodeSamples_1.default, {
168
+ example: xmlExample,
169
169
  language: "xml",
170
170
  })
171
171
  )
@@ -181,8 +181,8 @@ const ExampleFromSchema = ({ schema, mimeType }) => {
181
181
  react_1.default.createElement(
182
182
  TabItem_1.default,
183
183
  { label: "Example (auto)", value: "Example (auto)" },
184
- react_1.default.createElement(ResponseSamples_1.default, {
185
- responseExample: JSON.stringify(responseExample, null, 2),
184
+ react_1.default.createElement(CodeSamples_1.default, {
185
+ example: JSON.stringify(responseExample, null, 2),
186
186
  language: "json",
187
187
  })
188
188
  )