docusaurus-theme-openapi-docs 2.0.0-beta.5 → 2.0.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.
|
@@ -141,6 +141,10 @@ async function makeRequest(request, proxy, _body) {
|
|
|
141
141
|
if (data.key && data.value.content) {
|
|
142
142
|
myBody.append(data.key, data.value.content);
|
|
143
143
|
}
|
|
144
|
+
// handle generic key-value payload
|
|
145
|
+
if (data.key && typeof data.value === "string") {
|
|
146
|
+
myBody.append(data.key, data.value);
|
|
147
|
+
}
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
break;
|
|
@@ -166,7 +170,52 @@ async function makeRequest(request, proxy, _body) {
|
|
|
166
170
|
let normalizedProxy = proxy.replace(/\/$/, "") + "/";
|
|
167
171
|
finalUrl = normalizedProxy + request.url.toString();
|
|
168
172
|
}
|
|
169
|
-
return
|
|
173
|
+
return fetchWithtimeout(finalUrl, requestOptions).then((response) => {
|
|
174
|
+
const contentType = response.headers.get("content-type");
|
|
175
|
+
let fileExtension = "";
|
|
176
|
+
if (contentType) {
|
|
177
|
+
if (contentType.includes("application/pdf")) {
|
|
178
|
+
fileExtension = ".pdf";
|
|
179
|
+
} else if (contentType.includes("image/jpeg")) {
|
|
180
|
+
fileExtension = ".jpg";
|
|
181
|
+
} else if (contentType.includes("image/png")) {
|
|
182
|
+
fileExtension = ".png";
|
|
183
|
+
} else if (contentType.includes("image/gif")) {
|
|
184
|
+
fileExtension = ".gif";
|
|
185
|
+
} else if (contentType.includes("image/webp")) {
|
|
186
|
+
fileExtension = ".webp";
|
|
187
|
+
} else if (contentType.includes("video/mpeg")) {
|
|
188
|
+
fileExtension = ".mpeg";
|
|
189
|
+
} else if (contentType.includes("video/mp4")) {
|
|
190
|
+
fileExtension = ".mp4";
|
|
191
|
+
} else if (contentType.includes("audio/mpeg")) {
|
|
192
|
+
fileExtension = ".mp3";
|
|
193
|
+
} else if (contentType.includes("audio/ogg")) {
|
|
194
|
+
fileExtension = ".ogg";
|
|
195
|
+
} else if (contentType.includes("application/octet-stream")) {
|
|
196
|
+
fileExtension = ".bin";
|
|
197
|
+
} else if (contentType.includes("application/zip")) {
|
|
198
|
+
fileExtension = ".zip";
|
|
199
|
+
}
|
|
200
|
+
if (fileExtension) {
|
|
201
|
+
return response.blob().then((blob) => {
|
|
202
|
+
const url = window.URL.createObjectURL(blob);
|
|
203
|
+
const link = document.createElement("a");
|
|
204
|
+
link.href = url;
|
|
205
|
+
// Now the file name includes the extension
|
|
206
|
+
link.setAttribute("download", `file${fileExtension}`);
|
|
207
|
+
// These two lines are necessary to make the link click in Firefox
|
|
208
|
+
link.style.display = "none";
|
|
209
|
+
document.body.appendChild(link);
|
|
210
|
+
link.click();
|
|
211
|
+
// After link is clicked, it's safe to remove it.
|
|
212
|
+
setTimeout(() => document.body.removeChild(link), 0);
|
|
213
|
+
return response;
|
|
214
|
+
});
|
|
215
|
+
} else {
|
|
216
|
+
return response;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
170
219
|
return response;
|
|
171
220
|
});
|
|
172
221
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\""
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/types": ">=2.
|
|
31
|
+
"@docusaurus/types": ">=2.4.1 <=2.4.3",
|
|
32
32
|
"@types/crypto-js": "^4.1.0",
|
|
33
33
|
"@types/file-saver": "^2.0.5",
|
|
34
34
|
"@types/lodash": "^4.14.176",
|
|
35
35
|
"concurrently": "^5.2.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/theme-common": ">=2.
|
|
38
|
+
"@docusaurus/theme-common": ">=2.4.1 <=2.4.3",
|
|
39
39
|
"@hookform/error-message": "^2.0.1",
|
|
40
40
|
"@paloaltonetworks/postman-code-generators": "1.1.15-patch.2",
|
|
41
41
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"clsx": "^1.1.1",
|
|
44
44
|
"copy-text-to-clipboard": "^3.1.0",
|
|
45
45
|
"crypto-js": "^4.1.1",
|
|
46
|
-
"docusaurus-plugin-openapi-docs": "^2.0.
|
|
46
|
+
"docusaurus-plugin-openapi-docs": "^2.0.1",
|
|
47
47
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
48
48
|
"file-saver": "^2.0.5",
|
|
49
49
|
"lodash": "^4.17.20",
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
"xml-formatter": "^2.6.1"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"react": "^16.8.4 || ^17.0.0",
|
|
66
|
-
"react-dom": "^16.8.4 || ^17.0.0"
|
|
65
|
+
"react": "^16.8.4 || ^17.0.0 || ^18.0.0",
|
|
66
|
+
"react-dom": "^16.8.4 || ^17.0.0 || ^18.0.0"
|
|
67
67
|
},
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "6f9eff64e6b32c63100daaa7f70431edc8cf455d"
|
|
72
72
|
}
|
|
@@ -161,6 +161,10 @@ async function makeRequest(
|
|
|
161
161
|
if (data.key && data.value.content) {
|
|
162
162
|
myBody.append(data.key, data.value.content);
|
|
163
163
|
}
|
|
164
|
+
// handle generic key-value payload
|
|
165
|
+
if (data.key && typeof data.value === "string") {
|
|
166
|
+
myBody.append(data.key, data.value);
|
|
167
|
+
}
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
170
|
break;
|
|
@@ -189,11 +193,62 @@ async function makeRequest(
|
|
|
189
193
|
finalUrl = normalizedProxy + request.url.toString();
|
|
190
194
|
}
|
|
191
195
|
|
|
192
|
-
return
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
return fetchWithtimeout(finalUrl, requestOptions).then((response: any) => {
|
|
197
|
+
const contentType = response.headers.get("content-type");
|
|
198
|
+
let fileExtension = "";
|
|
199
|
+
|
|
200
|
+
if (contentType) {
|
|
201
|
+
if (contentType.includes("application/pdf")) {
|
|
202
|
+
fileExtension = ".pdf";
|
|
203
|
+
} else if (contentType.includes("image/jpeg")) {
|
|
204
|
+
fileExtension = ".jpg";
|
|
205
|
+
} else if (contentType.includes("image/png")) {
|
|
206
|
+
fileExtension = ".png";
|
|
207
|
+
} else if (contentType.includes("image/gif")) {
|
|
208
|
+
fileExtension = ".gif";
|
|
209
|
+
} else if (contentType.includes("image/webp")) {
|
|
210
|
+
fileExtension = ".webp";
|
|
211
|
+
} else if (contentType.includes("video/mpeg")) {
|
|
212
|
+
fileExtension = ".mpeg";
|
|
213
|
+
} else if (contentType.includes("video/mp4")) {
|
|
214
|
+
fileExtension = ".mp4";
|
|
215
|
+
} else if (contentType.includes("audio/mpeg")) {
|
|
216
|
+
fileExtension = ".mp3";
|
|
217
|
+
} else if (contentType.includes("audio/ogg")) {
|
|
218
|
+
fileExtension = ".ogg";
|
|
219
|
+
} else if (contentType.includes("application/octet-stream")) {
|
|
220
|
+
fileExtension = ".bin";
|
|
221
|
+
} else if (contentType.includes("application/zip")) {
|
|
222
|
+
fileExtension = ".zip";
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (fileExtension) {
|
|
226
|
+
return response.blob().then((blob: any) => {
|
|
227
|
+
const url = window.URL.createObjectURL(blob);
|
|
228
|
+
|
|
229
|
+
const link = document.createElement("a");
|
|
230
|
+
link.href = url;
|
|
231
|
+
// Now the file name includes the extension
|
|
232
|
+
link.setAttribute("download", `file${fileExtension}`);
|
|
233
|
+
|
|
234
|
+
// These two lines are necessary to make the link click in Firefox
|
|
235
|
+
link.style.display = "none";
|
|
236
|
+
document.body.appendChild(link);
|
|
237
|
+
|
|
238
|
+
link.click();
|
|
239
|
+
|
|
240
|
+
// After link is clicked, it's safe to remove it.
|
|
241
|
+
setTimeout(() => document.body.removeChild(link), 0);
|
|
242
|
+
|
|
243
|
+
return response;
|
|
244
|
+
});
|
|
245
|
+
} else {
|
|
246
|
+
return response;
|
|
247
|
+
}
|
|
195
248
|
}
|
|
196
|
-
|
|
249
|
+
|
|
250
|
+
return response;
|
|
251
|
+
});
|
|
197
252
|
}
|
|
198
253
|
|
|
199
254
|
export default makeRequest;
|