swagger-api / swagger-api/swagger-codegen

[Typescript-Anuglar] responseType not set on string response

Open
#8,399 5 comments 10 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

If response is a string, i get the following error when consuming the generated service:

Http failure during parsing for {API_URL}

Generated service:

return this.httpClient.get<string>(`${this.basePath}/accounts/${encodeURIComponent(String(accountName))}/account_name`,
            {
                withCredentials: this.configuration.withCredentials,
                headers: headers,
                observe: observe,
                reportProgress: reportProgress
            }
        );

If i add the line responseType: 'text' as 'json' to the options, everything works as expected.

Swagger-codegen version

2.3.1
2.4.0

Swagger declaration file content or url
"responses": {
"200": {
"description": "Returns account name for id",
"schema": {
"type": "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

Start in the TypeScript-Angular generator templates and reproduce the issue with the provided response schema. Verify that a generated service for a string response sets the HTTP response type to text and that the resulting request no longer fails during parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.