OpenAPITools / OpenAPITools/openapi-generator
[BUG][Typescript] - Error information is deleted
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When a request to an API encounters an error it will not have the information from the error because the library tries to parse it to the expected response. See the code below.
body = ObjectSerializer.deserialize(body, "UpdateSubmissionResponseContent");
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
Ideally it should be something like:
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = ObjectSerializer.deserialize(body, "UpdateSubmissionResponseContent");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
openapi-generator version
5.2.2
OpenAPI declaration file content or url
Not relevant
Generation Details
gradle swagger codegen
Steps to reproduce
- Generate any API client
- Make a request that gets a non 2xx response
- Try to parse the error
Related issues/PRs
N/A
Suggest a fix
Move the deserialization of body to happen only on 2xx response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the TypeScript client request flow that calls ObjectSerializer.deserialize with the expected response type. Reproduce a non-2xx response from a generated client and compare the error body before and after deserialization. Done means successful responses are still deserialized while HttpError receives the original error body.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100