[REQ] Honor MIME types specified in body Content-Type header
Created by: dmcguire81
Is your feature request related to a problem? Please describe.
Several of the generators we've used (rust, typescript-axios, swift5) forcefully serialize and deserialize request/response bodies to JSON irrespective of the setting of the Content-Type
header. For example, see this needsSerialization declaration, which serializes to JSON any body argument that is not a string
, when the underlying library, axios
, will happily handle native types that correspond to useful MIME types like image/*
, etc.
This leaves me in a bind as an API designer: either use correct MIME types that tools like cURL and Postman handle well and forego meaningful code generation, or forego external, code-agnostic testing and diagnostic tools, and get code that works on shallow application/json
-based objects that have MIME-types embedded in them.
Describe the solution you'd like
I'd like to be able to use native MIME types where appropriate and useful.
Describe alternatives you've considered
Modeling media as shallow objects that will encode to application/json
, just for the purposes of code-generation.
Additional context
Really, this is a philosophical question about how the owners see this tool being used. Should I file defects when I encode MIME types and they are not respected, as detailed above? Should I just make peace with the trade-offs, as described, and choose as best I can?