swagger-api / swagger-api/swagger-codegen
[Typescript-Angular] String response not handled correctly
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Endpoints that return a string are not handled correctly by the generated Typescript-Angular client. As per https://angular.io/guide/http#requesting-non-json-data if the response type is not json, then a type param should not be provided.
Swagger-codegen version
First identified in 2.3.0, still existing in master.
Command line used for generation
./bin/typescript-angular-petstore-all.sh
Steps to reproduce
- Run the script and see that in the
user.service.tsfile, the login method callsreturn this.httpClient.get<string>(${this.basePath}/user/login`` - The
<string>should not be there
Related issues/PRs
Most similar issue is the same thing but when the spec returns a file type instead of a string.
Suggest a fix/enhancement
I have some code which I will push which removes the <string> if the response type is a string.
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
Run ./bin/typescript-angular-petstore-all.sh and inspect the generated user.service.ts login method. Trace the Typescript-Angular generator template responsible for the request, then verify that string responses omit the type parameter and that the generated client still handles other response types correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100