Response "Content type" drop-down sets HTTP "Accept" header
See original GitHub issueUsing swagger-ui 3 and the petstore example, as deployed here: http://petstore.swagger.io.
For each operation, swagger-ui shows a list of response content types to choose from.

The list is populated from the “Produces” section in the OpenAPI (v2) specification file. For example:
"produces": [
"application/json",
"application/vnd.geo+json",
"application/vnd.google-earth.kml+xml",
"application/gml+xml",
"application/text+csv"
],
Swagger-ui assumes that it should send an “Accept” header with a value of the selected content type with every request. This is not a good idea because not all APIs make use of the “Accept” header to specify the output format. For example, an API could instead use a query string parameter to specify output format. In that case, sending the “Accept” header is unnecessary, and the “Content Type” drop-down list is misleading because it doesn’t affect the response.
Ideally the OpenAPI Specification would provide a way to define how an API allows users to specify the output format. I’m not aware of a way in which OpenAPI v2 allows us to do this currently. Does anyone know if OpenAPI v3 will provide a way to do this?
In the mean time, can we have an option to remove the “Content Type” drop-down list (and its control of the “Accept” header) from swagger-ui?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
This is not going to be part of OAS3, and hopefully not a part of any other future versions. REST APIs are HTTP based, they use HTTP constructs. Content is negotiated using two headers -
content-typefor the payload, andacceptfor what the client expects to accept.If you want to specify the content type using a query parameter, you’re welcome to do so, but the spec is not the right tool for the job. We’re not going to change the behavior. Of course, you’re welcome to write a plugin of your own to the system and change the behavior to suit your needs.
I created a solution that worked fine for me.
Uncommeted the
OperationFilterwith a class to empty the produces and add my Accept header parameters. And inject a JS file to remove all"response-content-type"divs. Code below.Without that, the Accept header gets a
application/jsonbefore my Accept parameter value ("application/json; charset=utf-8; version=v3") be added, resulting in:"application/json, application/json; charset=utf-8; version=v3"or"application/json, charset=utf-8; version=v3"if I remove theapplication/jsonfrom the my default settings. It gets a comma after the default response content typeapplication/json. Even I also using comma in my accept parameter it does not work,. That breaks the server to get my controller version parameter.The solution remove completely the default response content type
application/jsonto get only my Accept header parameter settings.