Open msnteixeira opened 4 months ago
I have the same issue, however, I use https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc plugin, but it is possible that it uses swagger-codegen underneath.
Description
T.L.D.R.: The selectHeaderAccept is removing values of the accept header
When working in JAVA and generating code using swagger-codegen-maven-plugin, the code generated contains in ApiClient.java the method
public List<MediaType> selectHeaderAccept(String[] accepts)
:This method iterates over the values of accept header and returns early if JSON exists in the array. This verification is done using the
public boolean isJsonMime(MediaType mediaType)
:If the Accept header contains
application/problem+json
andapplication/json
, and the client expectsapplication/json
, an error will occur since theselectHeaderAccept
method returns early with a single value (effectively removing other possible JSON values) when it shouldn't.Swagger-codegen version
latest, 3.0.58
Command line used for generation
Generated using swagger-codegen-maven-plugin
Steps to reproduce
Suggest a fix/enhancement
Consider avoiding the premature optimization of returning the first isJsonMime found in the given Accept header array.