Open JLLeitschuh opened 7 years ago
@JLLeitschuh swagger codegen (more precisely swagger parser) also supports global consumes and produces with an option to override the default (global) setting per operation.
Below is an example on how to reset the consumes
to nothing (empty array):
consumes: []
Would this resolve the issue for you?
I suppose it would. It's annoying that you need to put it on every get
method.
I would say that's the right way to do it as the spec should be the source of truth describing the REST API.
There are many tools built on top of Swagger/OpenAPI spec and I'm not aware of any implementing the logic you described as likely other tools also assume the consumes
is correctly defined.
Description
In the Swagger UI if you have a global
consumes
set then all of the controllers (for example in spring) will have theconsumes
annotation filled in. This makes the swagger-ui not work for GET and DELETE.You can read the discussion as to why here: https://github.com/swagger-api/swagger-ui/issues/2408
Basically it comes down to this:
Swagger-codegen version
Latest master
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Have your swagger spec declare that it consumes some mime type
Try to send a GET request with the swagger-ui inside of spring with your API being generated with spring fox.
You will get a 415 error from spring because you haven't passed the
Content-Type
header.Suggest a Fix
Options:
consumes
field in the spring (and probably other) controllers should not be populated on get and delete requests.consumes
global field should be ignored but the one directly on the get request should be respected. Eg: