docusaurus-theme-openapi-docs 0.0.0-1103 → 0.0.0-1105
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/Request/index.js +3 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +3 -1
- package/lib/theme/ApiExplorer/Response/index.js +96 -11
- package/package.json +3 -3
- package/src/theme/ApiExplorer/Request/index.tsx +3 -1
- package/src/theme/ApiExplorer/Request/makeRequest.ts +3 -1
- package/src/theme/ApiExplorer/Response/index.tsx +32 -12
- package/src/types.d.ts +7 -0
|
@@ -103,6 +103,7 @@ function Request({ item }) {
|
|
|
103
103
|
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
104
104
|
const themeConfig = siteConfig.themeConfig;
|
|
105
105
|
const requestTimeout = themeConfig.api?.requestTimeout;
|
|
106
|
+
const requestCredentials = themeConfig.api?.requestCredentials;
|
|
106
107
|
// Frontmatter proxy (per-spec) takes precedence over theme config proxy (site-wide)
|
|
107
108
|
const proxy = frontMatterProxy ?? themeConfig.api?.proxy;
|
|
108
109
|
const pathParams = (0, hooks_1.useTypedSelector)(
|
|
@@ -233,7 +234,8 @@ function Request({ item }) {
|
|
|
233
234
|
postmanRequest,
|
|
234
235
|
proxy,
|
|
235
236
|
body,
|
|
236
|
-
requestTimeout
|
|
237
|
+
requestTimeout,
|
|
238
|
+
requestCredentials
|
|
237
239
|
);
|
|
238
240
|
if (res.headers.get("content-type")?.includes("text/event-stream")) {
|
|
239
241
|
await handleEventStream(res);
|
|
@@ -6,5 +6,5 @@ export declare class RequestError extends Error {
|
|
|
6
6
|
originalError?: Error;
|
|
7
7
|
constructor(type: RequestErrorType, message: string, originalError?: Error);
|
|
8
8
|
}
|
|
9
|
-
declare function makeRequest(request: sdk.Request, proxy: string | undefined, _body: Body, timeout?: number): Promise<Response>;
|
|
9
|
+
declare function makeRequest(request: sdk.Request, proxy: string | undefined, _body: Body, timeout?: number, credentials?: RequestCredentials): Promise<Response>;
|
|
10
10
|
export default makeRequest;
|
|
@@ -89,7 +89,8 @@ async function makeRequest(
|
|
|
89
89
|
request,
|
|
90
90
|
proxy,
|
|
91
91
|
_body,
|
|
92
|
-
timeout = DEFAULT_REQUEST_TIMEOUT
|
|
92
|
+
timeout = DEFAULT_REQUEST_TIMEOUT,
|
|
93
|
+
credentials
|
|
93
94
|
) {
|
|
94
95
|
const headers = request.toJSON().header;
|
|
95
96
|
let myHeaders = new Headers();
|
|
@@ -221,6 +222,7 @@ async function makeRequest(
|
|
|
221
222
|
method: request.method,
|
|
222
223
|
headers: myHeaders,
|
|
223
224
|
body: myBody,
|
|
225
|
+
...(credentials && { credentials }),
|
|
224
226
|
};
|
|
225
227
|
let finalUrl = request.url.toString();
|
|
226
228
|
if (proxy) {
|
|
@@ -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) {
|
|
@@ -14,7 +70,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
70
|
const react_1 = __importDefault(require("react"));
|
|
15
71
|
const client_1 = require("@docusaurus/plugin-content-docs/client");
|
|
16
72
|
const theme_common_1 = require("@docusaurus/theme-common");
|
|
17
|
-
const Translate_1 = require("@docusaurus/Translate");
|
|
73
|
+
const Translate_1 = __importStar(require("@docusaurus/Translate"));
|
|
18
74
|
const useDocusaurusContext_1 = __importDefault(
|
|
19
75
|
require("@docusaurus/useDocusaurusContext")
|
|
20
76
|
);
|
|
@@ -157,11 +213,27 @@ function Response({ item }) {
|
|
|
157
213
|
className:
|
|
158
214
|
"openapi-explorer__response-placeholder-message",
|
|
159
215
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
216
|
+
react_1.default.createElement(
|
|
217
|
+
Translate_1.default,
|
|
218
|
+
{
|
|
219
|
+
id: translationIds_1.OPENAPI_RESPONSE.PLACEHOLDER,
|
|
220
|
+
values: {
|
|
221
|
+
code: react_1.default.createElement(
|
|
222
|
+
"code",
|
|
223
|
+
null,
|
|
224
|
+
react_1.default.createElement(
|
|
225
|
+
Translate_1.default,
|
|
226
|
+
{
|
|
227
|
+
id: translationIds_1.OPENAPI_REQUEST
|
|
228
|
+
.SEND_BUTTON,
|
|
229
|
+
},
|
|
230
|
+
"Send API Request"
|
|
231
|
+
)
|
|
232
|
+
),
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
"Click the {code} button above and see the response here!"
|
|
236
|
+
)
|
|
165
237
|
)
|
|
166
238
|
)
|
|
167
239
|
),
|
|
@@ -201,11 +273,24 @@ function Response({ item }) {
|
|
|
201
273
|
: react_1.default.createElement(
|
|
202
274
|
"p",
|
|
203
275
|
{ className: "openapi-explorer__response-placeholder-message" },
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
276
|
+
react_1.default.createElement(
|
|
277
|
+
Translate_1.default,
|
|
278
|
+
{
|
|
279
|
+
id: translationIds_1.OPENAPI_RESPONSE.PLACEHOLDER,
|
|
280
|
+
values: {
|
|
281
|
+
code: react_1.default.createElement(
|
|
282
|
+
"code",
|
|
283
|
+
null,
|
|
284
|
+
react_1.default.createElement(
|
|
285
|
+
Translate_1.default,
|
|
286
|
+
{ id: translationIds_1.OPENAPI_REQUEST.SEND_BUTTON },
|
|
287
|
+
"Send API Request"
|
|
288
|
+
)
|
|
289
|
+
),
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
"Click the {code} button above and see the response here!"
|
|
293
|
+
)
|
|
209
294
|
)
|
|
210
295
|
)
|
|
211
296
|
);
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-1105",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/postman-collection": "^3.5.11",
|
|
39
39
|
"@types/react-modal": "^3.16.3",
|
|
40
40
|
"concurrently": "^9.2.0",
|
|
41
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1105",
|
|
42
42
|
"docusaurus-plugin-sass": "^0.2.6",
|
|
43
43
|
"eslint-plugin-prettier": "^5.5.1"
|
|
44
44
|
},
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=14"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "5a573d71d569e71efd1a08fc4abbd4c822533e55"
|
|
85
85
|
}
|
|
@@ -43,6 +43,7 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
43
43
|
const { siteConfig } = useDocusaurusContext();
|
|
44
44
|
const themeConfig = siteConfig.themeConfig as ThemeConfig;
|
|
45
45
|
const requestTimeout = themeConfig.api?.requestTimeout;
|
|
46
|
+
const requestCredentials = themeConfig.api?.requestCredentials;
|
|
46
47
|
// Frontmatter proxy (per-spec) takes precedence over theme config proxy (site-wide)
|
|
47
48
|
const proxy = frontMatterProxy ?? themeConfig.api?.proxy;
|
|
48
49
|
|
|
@@ -171,7 +172,8 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
171
172
|
postmanRequest,
|
|
172
173
|
proxy,
|
|
173
174
|
body,
|
|
174
|
-
requestTimeout
|
|
175
|
+
requestTimeout,
|
|
176
|
+
requestCredentials
|
|
175
177
|
);
|
|
176
178
|
if (res.headers.get("content-type")?.includes("text/event-stream")) {
|
|
177
179
|
await handleEventStream(res);
|
|
@@ -114,7 +114,8 @@ async function makeRequest(
|
|
|
114
114
|
request: sdk.Request,
|
|
115
115
|
proxy: string | undefined,
|
|
116
116
|
_body: Body,
|
|
117
|
-
timeout: number = DEFAULT_REQUEST_TIMEOUT
|
|
117
|
+
timeout: number = DEFAULT_REQUEST_TIMEOUT,
|
|
118
|
+
credentials?: RequestCredentials
|
|
118
119
|
) {
|
|
119
120
|
const headers = request.toJSON().header;
|
|
120
121
|
|
|
@@ -252,6 +253,7 @@ async function makeRequest(
|
|
|
252
253
|
method: request.method,
|
|
253
254
|
headers: myHeaders,
|
|
254
255
|
body: myBody,
|
|
256
|
+
...(credentials && { credentials }),
|
|
255
257
|
};
|
|
256
258
|
|
|
257
259
|
let finalUrl = request.url.toString();
|
|
@@ -9,13 +9,13 @@ import React from "react";
|
|
|
9
9
|
|
|
10
10
|
import { useDoc } from "@docusaurus/plugin-content-docs/client";
|
|
11
11
|
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
12
|
-
import { translate } from "@docusaurus/Translate";
|
|
12
|
+
import Translate, { translate } from "@docusaurus/Translate";
|
|
13
13
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
14
14
|
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
15
15
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
16
16
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
17
17
|
import TabItem from "@theme/TabItem";
|
|
18
|
-
import { OPENAPI_RESPONSE } from "@theme/translationIds";
|
|
18
|
+
import { OPENAPI_REQUEST, OPENAPI_RESPONSE } from "@theme/translationIds";
|
|
19
19
|
import clsx from "clsx";
|
|
20
20
|
import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
21
21
|
import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
|
|
@@ -126,11 +126,22 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
126
126
|
>
|
|
127
127
|
{prettyResponse || (
|
|
128
128
|
<p className="openapi-explorer__response-placeholder-message">
|
|
129
|
-
|
|
130
|
-
id
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
<Translate
|
|
130
|
+
id={OPENAPI_RESPONSE.PLACEHOLDER}
|
|
131
|
+
values={{
|
|
132
|
+
code: (
|
|
133
|
+
<code>
|
|
134
|
+
<Translate id={OPENAPI_REQUEST.SEND_BUTTON}>
|
|
135
|
+
Send API Request
|
|
136
|
+
</Translate>
|
|
137
|
+
</code>
|
|
138
|
+
),
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
{
|
|
142
|
+
"Click the {code} button above and see the response here!"
|
|
143
|
+
}
|
|
144
|
+
</Translate>
|
|
134
145
|
</p>
|
|
135
146
|
)}
|
|
136
147
|
</ApiCodeBlock>
|
|
@@ -163,11 +174,20 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
163
174
|
</div>
|
|
164
175
|
) : (
|
|
165
176
|
<p className="openapi-explorer__response-placeholder-message">
|
|
166
|
-
|
|
167
|
-
id
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
177
|
+
<Translate
|
|
178
|
+
id={OPENAPI_RESPONSE.PLACEHOLDER}
|
|
179
|
+
values={{
|
|
180
|
+
code: (
|
|
181
|
+
<code>
|
|
182
|
+
<Translate id={OPENAPI_REQUEST.SEND_BUTTON}>
|
|
183
|
+
Send API Request
|
|
184
|
+
</Translate>
|
|
185
|
+
</code>
|
|
186
|
+
),
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
{"Click the {code} button above and see the response here!"}
|
|
190
|
+
</Translate>
|
|
171
191
|
</p>
|
|
172
192
|
)}
|
|
173
193
|
</div>
|
package/src/types.d.ts
CHANGED
|
@@ -27,6 +27,13 @@ export interface ThemeConfig {
|
|
|
27
27
|
authPersistence?: false | "sessionStorage" | "localStorage";
|
|
28
28
|
/** Request timeout in milliseconds. Defaults to 30000 (30 seconds). */
|
|
29
29
|
requestTimeout?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Controls whether cookies and credentials are sent with API requests.
|
|
32
|
+
* - `"omit"`: Never send cookies (useful when docs are on same domain as app)
|
|
33
|
+
* - `"same-origin"`: Send cookies for same-origin requests (default browser behavior)
|
|
34
|
+
* - `"include"`: Always send cookies, even for cross-origin requests
|
|
35
|
+
*/
|
|
36
|
+
requestCredentials?: "omit" | "same-origin" | "include";
|
|
30
37
|
};
|
|
31
38
|
}
|
|
32
39
|
|