- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 135
ResponseValidator: how to handle mime-type with character encoding details? #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Personally, I worked around this by specifying the response mimetype in the spec as "application/json; UTF-8", e.g.
I see that you mentioned trying that and encountering errors. Perhaps they're being caused by something else? |
Not sure if such work around actually works, hence I provided a test: Run "as is":
after the updating the content-type in test spec from
By updating the spec I would expect the validation for the second validate() call to work, but that does not appear to be the case. Am I overlooking something? |
Looking back, I see there was one more element I needed for my workaround:
|
While using
ResponseValidator.validate
I noticed validation is sensitive to the content-type header including character encoding details.In case an HTTP response includes
content-type: application/json; charset=utf-8
validation fails:MediaTypeNotFound(mimetype='application/json; charset=utf-8', availableMimetypes=['application/json'])
(As quick work I tried adding
application/json; charset=utf-8
to the openapi spec as additional mime-type but that results in vague errors such as raised in #128)I can manually overwrite
mimetype
of the response before validating but that feels a bit wrong .. one could reason thatapplication/json; charset=utf-8
should be accepted and treated equal asapplication/json
. Any comment?See below for code that reproduces this situation.
The text was updated successfully, but these errors were encountered: