OpenAPITools / OpenAPITools/openapi-generator

[REQ] [typescript-fetch] option to not throw ResponseError

Open
#21,467 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

https://github.com/OpenAPITools/openapi-generator/blob/d911a71be93ae2a256533ccd5808b245258f9fa8/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache#L126-L129

It would be great to have a boolean doNotThrowOnNon2xx option, since non-2xx responses are often part of normal control flow and may contain useful response bodies, avoiding the need for try/catch everywhere. Additionally, the native fetch API (e.g. in browsers or with undici in Node) does not throw on non-2xx responses, so this behaviour is unexpected and inconsistent with the underlying transport.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache at lines 126-129 and trace how non-2xx responses become ResponseError instances. Add the boolean option so callers can receive non-2xx responses without an exception, while preserving useful response bodies; verify the generated typescript-fetch client behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.