Open xlegalles opened 6 years ago
Is there any news on this? This produces big problems on our side because the Openapi Generator v6
packages check the content type exactly:
application/json
application/json; charset=utf-8
exceptions.ApiValueError: Invalid content_type returned. Content_type='application/json; charset=utf-8' was returned when only {'application/json'} are defined for status_code=201
Update
We got our problem fixed by simply allowing both content types:
[Produces(System.Net.Mime.MediaTypeNames.Application.Json, "application/json; charset=utf-8")]
VERSION:
2.3.0 and ASP.NET Core 2.1
STEPS TO REPRODUCE:
We describe an API using attributes. For example
Which provides the typical result in the
swagger.json
file:But there is no way to specify a response of type
"application/json; charset=utf-8"
which is btw exactly what a browser will receive from the previous method. So there is a slight difference between a real answer and the swagger description.I've tried adding a
[Produces("application/json;charset=utf-8")]
at the controller level or at the method level but it does not change anything. I don't find any way to add the charset definition into the swagger file.You may think that this is a detail but it is not when we test the API using PACT:
"application/json; charset=utf-8"
header with a charset. And tests fail.Thank you for your help