docusaurus-theme-openapi-docs 4.3.7 → 4.5.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/theme/ApiExplorer/ApiCodeBlock/Content/String.js +3 -3
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +5 -1
- package/lib/theme/ApiExplorer/Authorization/slice.js +2 -2
- package/lib/theme/ApiExplorer/Body/slice.js +2 -2
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +3 -3
- package/lib/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +4 -2
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +4 -4
- package/lib/theme/ApiExplorer/Request/index.js +27 -6
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +3 -2
- package/lib/theme/ApiExplorer/Response/slice.js +2 -2
- package/lib/theme/ApiExplorer/Server/slice.js +2 -2
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +119 -46
- package/lib/theme/ApiExplorer/index.js +58 -2
- package/lib/theme/CodeSamples/_CodeSamples.scss +3 -0
- package/lib/theme/CodeSamples/index.d.ts +8 -0
- package/lib/theme/{ResponseSamples → CodeSamples}/index.js +4 -4
- package/lib/theme/ParamsItem/index.d.ts +1 -4
- package/lib/theme/ParamsItem/index.js +4 -1
- package/lib/theme/ResponseExamples/index.js +9 -9
- package/lib/theme/Schema/index.js +73 -133
- package/lib/theme/SchemaItem/index.js +34 -0
- package/lib/theme/styles.scss +1 -1
- package/lib/types.d.ts +5 -116
- package/package.json +5 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +3 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.tsx +5 -1
- package/src/theme/ApiExplorer/Body/index.tsx +1 -2
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +3 -3
- package/src/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +4 -2
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +4 -4
- package/src/theme/ApiExplorer/Request/index.tsx +28 -5
- package/src/theme/ApiExplorer/Request/makeRequest.ts +4 -3
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +48 -18
- package/src/theme/ApiExplorer/index.tsx +4 -2
- package/src/theme/CodeSamples/_CodeSamples.scss +3 -0
- package/src/theme/{ResponseSamples → CodeSamples}/index.tsx +5 -10
- package/src/theme/ParamsItem/index.tsx +7 -6
- package/src/theme/ResponseExamples/index.tsx +6 -9
- package/src/theme/Schema/index.tsx +69 -96
- package/src/theme/SchemaItem/index.tsx +27 -0
- package/src/theme/styles.scss +1 -1
- package/src/types.ts +5 -115
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/theme/ResponseSamples/_ResponseSamples.scss +0 -3
- package/lib/theme/ResponseSamples/index.d.ts +0 -8
- package/src/theme/ApiExplorer/postman-collection.d.ts +0 -10
- package/src/theme/ApiExplorer/react-modal.d.ts +0 -8
- package/src/theme/ResponseSamples/_ResponseSamples.scss +0 -3
- 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
|
-
|
|
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
|
|
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;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
&:hover {
|
|
15
15
|
border: 2px dashed var(--ifm-color-primary);
|
|
16
|
-
background:
|
|
16
|
+
background:
|
|
17
|
+
linear-gradient(
|
|
17
18
|
var(--openapi-dropzone-hover-shim),
|
|
18
19
|
var(--openapi-dropzone-hover-shim)
|
|
19
20
|
),
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
font-size: var(--ifm-code-font-size);
|
|
39
40
|
border: 2px dashed var(--ifm-color-primary);
|
|
40
41
|
|
|
41
|
-
background:
|
|
42
|
+
background:
|
|
43
|
+
linear-gradient(
|
|
42
44
|
var(--openapi-dropzone-hover-shim),
|
|
43
45
|
var(--openapi-dropzone-hover-shim)
|
|
44
46
|
),
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
line-height: 1.5;
|
|
46
46
|
|
|
47
47
|
transition-property: color, background, border-color, box-shadow;
|
|
48
|
-
transition-duration:
|
|
49
|
-
var(--ifm-button-transition-duration);
|
|
48
|
+
transition-duration:
|
|
49
|
+
100ms, 100ms, 100ms, var(--ifm-button-transition-duration);
|
|
50
50
|
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
51
51
|
|
|
52
52
|
-webkit-user-select: none;
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
padding: 0.5rem 1rem;
|
|
86
86
|
font-size: 12px;
|
|
87
87
|
transition-property: color, background, border-color, box-shadow;
|
|
88
|
-
transition-duration:
|
|
89
|
-
var(--ifm-button-transition-duration);
|
|
88
|
+
transition-duration:
|
|
89
|
+
100ms, 100ms, 100ms, var(--ifm-button-transition-duration);
|
|
90
90
|
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
91
91
|
user-select: none;
|
|
92
92
|
white-space: nowrap;
|
|
@@ -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
|
|
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
|
|
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)(
|
|
@@ -158,15 +158,36 @@ function Request({ item }) {
|
|
|
158
158
|
paramsArray.push(param);
|
|
159
159
|
});
|
|
160
160
|
const methods = (0, react_hook_form_1.useForm)({ shouldFocusError: false });
|
|
161
|
+
const handleEventStream = async (res) => {
|
|
162
|
+
res.headers &&
|
|
163
|
+
dispatch((0, slice_1.setHeaders)(Object.fromEntries(res.headers)));
|
|
164
|
+
dispatch((0, slice_1.setCode)(res.status));
|
|
165
|
+
const reader = res.body.getReader();
|
|
166
|
+
const decoder = new TextDecoder();
|
|
167
|
+
let result = "";
|
|
168
|
+
while (true) {
|
|
169
|
+
const { done, value } = await reader.read();
|
|
170
|
+
if (done) break;
|
|
171
|
+
result += decoder.decode(value, { stream: true });
|
|
172
|
+
dispatch((0, slice_1.setResponse)(result));
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const handleResponse = async (res) => {
|
|
176
|
+
dispatch((0, slice_1.setResponse)(await res.text()));
|
|
177
|
+
dispatch((0, slice_1.setCode)(res.status));
|
|
178
|
+
res.headers &&
|
|
179
|
+
dispatch((0, slice_1.setHeaders)(Object.fromEntries(res.headers)));
|
|
180
|
+
};
|
|
161
181
|
const onSubmit = async (data) => {
|
|
162
182
|
dispatch((0, slice_1.setResponse)("Fetching..."));
|
|
163
183
|
try {
|
|
164
184
|
await delay(1200);
|
|
165
185
|
const res = await (0, makeRequest_1.default)(postmanRequest, proxy, body);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
if (res.headers.get("content-type")?.includes("text/event-stream")) {
|
|
187
|
+
await handleEventStream(res);
|
|
188
|
+
} else {
|
|
189
|
+
await handleResponse(res);
|
|
190
|
+
}
|
|
170
191
|
} catch (e) {
|
|
171
192
|
console.log(e);
|
|
172
193
|
dispatch((0, slice_1.setResponse)("Connection failed"));
|
|
@@ -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
|
-
|
|
140
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
94
|
+
new sdk.QueryParam({
|
|
39
95
|
key: param.name,
|
|
40
96
|
value: val,
|
|
41
97
|
})
|
|
42
98
|
);
|
|
43
99
|
} else {
|
|
44
|
-
return new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
213
|
+
return new sdk.Variable({
|
|
158
214
|
key: param.name,
|
|
159
215
|
value: serializedValue,
|
|
160
216
|
});
|
|
161
217
|
});
|
|
162
|
-
postman.url.variables.assimilate(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
316
|
-
key: key,
|
|
317
|
-
...content,
|
|
318
|
-
});
|
|
380
|
+
return new sdk.FormParam({ key: key, ...content });
|
|
319
381
|
}
|
|
320
|
-
return new
|
|
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
|
|
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
|
-
|
|
383
|
-
|
|
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,9 @@ const Response_1 = __importDefault(require("@theme/ApiExplorer/Response"));
|
|
|
20
76
|
const SecuritySchemes_1 = __importDefault(
|
|
21
77
|
require("@theme/ApiExplorer/SecuritySchemes")
|
|
22
78
|
);
|
|
23
|
-
const
|
|
79
|
+
const sdk = __importStar(require("postman-collection"));
|
|
24
80
|
function ApiExplorer({ item, infoPath }) {
|
|
25
|
-
const postman = new
|
|
81
|
+
const postman = new sdk.Request(item.postman ? item.postman.toJSON() : {});
|
|
26
82
|
return react_1.default.createElement(
|
|
27
83
|
react_1.default.Fragment,
|
|
28
84
|
null,
|
|
@@ -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
|
|
16
|
+
function CodeSamples({ example, language }) {
|
|
17
17
|
return react_1.default.createElement(
|
|
18
18
|
"div",
|
|
19
|
-
{ className: "openapi-
|
|
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
|
-
|
|
23
|
+
example
|
|
24
24
|
)
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
-
exports.default =
|
|
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:
|
|
13
|
+
examples: Record<string, ExampleObject>;
|
|
17
14
|
name: string;
|
|
18
15
|
required: boolean;
|
|
19
16
|
deprecated: boolean;
|