swagger-api / swagger-api/swagger-codegen

[Typescript-Angular] String response not handled correctly

Open
#8,905 0 comments 0 reactions 0 assignees View on GitHub

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
  1. Run the script and see that in the user.service.ts file, the login method calls return this.httpClient.get<string>(${this.basePath}/user/login``
  2. 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.