swagger-api / swagger-api/swagger-codegen
[Typescript-Anuglar] responseType not set on string response
Open
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
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 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