You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve API request error handling and add support for customizing requestTimeout (#1267)
* feat(theme): improve error handling for API requests
- Add custom RequestError class with typed error categories (timeout, network, cors, unknown)
- Replace Promise.race timeout with AbortController for cleaner timeout handling
- Add descriptive error messages for different failure scenarios
- Add translation IDs for internationalization of error messages
- Update Request component to display context-specific error messages
* feat(theme): add configurable request timeout and site-wide proxy support
- Increase default request timeout from 5s to 30s
- Add requestTimeout option to themeConfig.api for site-wide configuration
- Support proxy in themeConfig.api as site-wide default (per-spec plugin option takes precedence)
- Update documentation in README.md, plugin README.md, and intro.mdx
|`specPath`|`string`|`null`| Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
161
-
|`outputDir`|`string`|`null`| Desired output path for generated MDX and sidebar files. |
162
-
|`proxy`|`string`|`null`|_Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
163
-
|`template`|`string`|`null`|_Optional:_ Customize MDX content with a desired template. |
164
-
|`infoTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **info** pages only. |
165
-
|`tagTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **tag** pages only. |
166
-
|`schemaTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **schema** pages only. |
|`specPath`|`string`|`null`| Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
161
+
|`outputDir`|`string`|`null`| Desired output path for generated MDX and sidebar files. |
162
+
|`proxy`|`string`|`null`|_Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. Overrides site-wide `themeConfig.api.proxy` if set.|
163
+
|`template`|`string`|`null`|_Optional:_ Customize MDX content with a desired template. |
164
+
|`infoTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **info** pages only. |
165
+
|`tagTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **tag** pages only. |
166
+
|`schemaTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **schema** pages only. |
|`proxy`|`string`|`null`|_Optional:_ Site-wide proxy URL to prepend to base URL when performing API requests. Can be overridden per-spec via plugin config. |
231
+
|`authPersistance`|`string`|`null`|_Optional:_ Determines how auth credentials are persisted. Options: `"localStorage"`, `"sessionStorage"`, or `false` to disable. |
232
+
|`requestTimeout`|`number`|`30000`|_Optional:_ Request timeout in milliseconds for API requests made from the browser. Defaults to 30 seconds. |
233
+
234
+
Example:
235
+
236
+
```typescript
237
+
// docusaurus.config.ts
238
+
{
239
+
themeConfig: {
240
+
api: {
241
+
proxy: "https://cors.pan.dev", // Site-wide proxy (can be overridden per-spec in plugin config)
|`specPath`|`string`|`null`| Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
208
208
|`outputDir`|`string`|`null`| Desired output path for generated MDX and sidebar files. |
209
-
|`proxy`|`string`|`null`|_Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
209
+
|`proxy`|`string`|`null`|_Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. Overrides site-wide `themeConfig.api.proxy` if set.|
210
210
|`template`|`string`|`null`|_Optional:_ Customize MDX content with a desired template. |
211
211
|`infoTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **info** pages only. |
212
212
|`tagTemplate`|`string`|`null`|_Optional:_ Customize MDX content for **tag** pages only. |
|`proxy`|`string`|`null`|_Optional:_ Site-wide proxy URL to prepend to base URL when performing API requests. Can be overridden per-spec via plugin config. |
295
+
|`authPersistance`|`string`|`null`|_Optional:_ Determines how auth credentials are persisted. Options: `"localStorage"`, `"sessionStorage"`, or `false` to disable. |
296
+
|`requestTimeout`|`number`|`30000`|_Optional:_ Request timeout in milliseconds for API requests made from the browser. Defaults to 30 seconds. |
297
+
298
+
Example:
299
+
300
+
```typescript
301
+
// docusaurus.config.ts
302
+
{
303
+
themeConfig: {
304
+
api: {
305
+
proxy: "https://cors.pan.dev", // Site-wide proxy (can be overridden per-spec in plugin config)
306
+
authPersistance: "localStorage",
307
+
requestTimeout: 60000, // 60 seconds
308
+
},
309
+
},
310
+
}
311
+
```
312
+
288
313
## CLI Usage
289
314
290
315
After you've installed and configured the plugin and theme, the CLI can be used to `generate` and `clean` API docs.
0 commit comments