swagger-api / swagger-api/swagger-codegen
[typescript-fetch] Add support for file (application/octet-stream) response types
@HugoMario is already working on this.
Since May 8, 2020.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Currently, swagger attempts to process file (application/octet-stream) response content as JSON. In particular, swagger calls response.json(), which results in an error.
Swagger-codegen version
v2.4.0 - master.
Swagger declaration file content or url
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response.json(); // Throws "Uncaught (in promise) SyntaxError: Unexpected token % in JSON at position 0"
} else {
throw response;
}
});
Command line used for generation
java -jar ./other_modules/swagger/swagger-codegen-cli.jar generate -i http://localhost:8011/swagger/v1/swagger.json -l typescript-fetch -o ./other_modules/swagger/output
Steps to reproduce
Run swagger-codegen against an API that produces application/octet-stream content.
Suggest a fix/enhancement
Modify the api.mustache file for typescript-fetch as need be (make reference to typescript-angular module where support for file response types has already been added), using the isResponseFile flag. When isResponseFile is true, return the response content as blob -> return response.blob();
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.
Assessment
This issue has not been assessed yet.