mtennoe / swagger-typescript-codegen

A Swagger Codegenerator tailored for typescript.
Apache License 2.0
140 stars 52 forks source link

Use lower case default headers #116

Closed sibbl closed 4 years ago

sibbl commented 4 years ago

When using produces or consumes in the swagger description there's currently a case mismatch between the casing of the code generator and superagent.

In my specific case, I have an endpoint consuming text/csv. Apparently, the body is of type string.

Internally, when sending a string to the endpoint res.send(body) is called. In the send method, superagent gets the content-type header (lower case, see here).

If it doesn't find it, the content type is overriden and set to application/x-www-form-urlencoded. Thus, my string body is sent as [object Object] to the backend because the content is transformed. This happens here.

If somebody considers this as a breaking change, I would also be happy by introducing a lowerCaseName field which then can be used in mustache files. However, I think sticking to the lower case header names convention of superagent is the better way to solve the issue.

Microsoft Reviewers: Open in CodeFlow
mtennoe commented 4 years ago

Looks like a test failure btw where some more snapshots need to be updated

mtennoe commented 4 years ago

The PR has been merged and published as 3.1.0. Thanks for the contribution!