swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Throws on formatter JSON when 204 No Content

Open theluk opened this issue 3 years ago • 0 comments

In general it makes sense to always set your formatter to JSON as most of the methods are JSON responses.

The only exception that would make sense to generally skip the formating step would be if the http response is a 204 NO CONTENT. This makes sense basically in all DELETE HTTP calls and in some other scenarios.

This would also comply with the case that a HttpResponse type could be void, which in general in our swagger scenario is the case for DELETE. I am not 100% sure how the standard is, but I think in general if the swagger definition can define the Response Type as void and it still tries to format to JSON, it is clear that it will not work out.

https://github.com/acacode/swagger-typescript-api/blob/37efbb9e5deb5f60b680994ad908332033f03fa8/templates/base/http-clients/fetch-http-client.eta#L194

theluk avatar Jun 18 '21 08:06 theluk