Description
In the TypeScript-Fetch client generator, payloads sent to any routes with body parameters are unconditionally tagged with a Content-Type of application/json and JSON.stringify-ed before being sent. Routes that expect content such as tar archives are broken by this behavior.
Swagger-codegen version
2.3.0-snapshot
Swagger declaration file content or url
https://raw.githubusercontent.com/moby/moby/master/api/swagger.yaml
See for example the PutContainerArchive operation route, which consumes: ["application/x-tar", "application/octet-stream"].
Command line used for generation
generate -i /moby/api/swagger.yaml -l typescript-fetch -o /package
Steps to reproduce
Generate the client with the linked spec (or use the docker-client package from npm, which is generated in this way), inspect the code for putContainerArchive and observe that it adds a Content-Type application/json header and invokes JSON.stringify on the content. If you actually try this against a Docker instance you'll get an invalid tar archive error.
Suggest a fix/enhancement
The codegen should look at the route's consumes attribute to figure out the content type header, and if it isn't JSON, send it through without JSON stringify-ing.
Description
In the TypeScript-Fetch client generator, payloads sent to any routes with body parameters are unconditionally tagged with a
Content-Typeofapplication/jsonandJSON.stringify-ed before being sent. Routes that expect content such as tar archives are broken by this behavior.Swagger-codegen version
2.3.0-snapshot
Swagger declaration file content or url
https://raw.githubusercontent.com/moby/moby/master/api/swagger.yaml
See for example the
PutContainerArchiveoperation route, whichconsumes: ["application/x-tar", "application/octet-stream"].Command line used for generation
Steps to reproduce
Generate the client with the linked spec (or use the
docker-clientpackage from npm, which is generated in this way), inspect the code forputContainerArchiveand observe that it adds aContent-Typeapplication/jsonheader and invokesJSON.stringifyon the content. If you actually try this against a Docker instance you'll get an invalid tar archive error.Suggest a fix/enhancement
The codegen should look at the route's
consumesattribute to figure out the content type header, and if it isn't JSON, send it through without JSON stringify-ing.