-
-
Notifications
You must be signed in to change notification settings - Fork 603
Open
Labels
bugSomething isn't workingSomething isn't workingopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript library
Description
openapi-typescript version
0.14.0
Node.js version
v22.20.0
OS + version
macOS 15.5
Description
I had to apply this patch to get proper error handling:
- const { data, error } = await this.client.POST(`/invitees`, {
+ const { data, error, response } = await this.client.POST(`/invitees`, {
body,
});
if (error) {
throw new ExInfo(`Error: ${error.message}`, {
data: { details: error.details },
cause: error,
});
}
+ if (!response.ok) {
+ throw new ExInfo(`Error: ${response.statusText}`, {
+ data: { details: response.statusText },
+ cause: response.statusText,
+ });
+ }
The reason is that error is sometimes undefined even though the server returned 4xx - specifically if the 4xx response is not mentioned in the openapi schema.
This happens with 429 Rate Limited errors which get added by Cloudflare (but not to the api spec).
Reproduction
Server response doesn't mention 429 error. Server returns 429 with no response body
Expected result
either
erroris set to some value- the docs state that you need to ALSO check response.ok
Required
- My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint)
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)
jmetrikat
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript library