unsupported media type for "application/json; charset=utf-8"
See original GitHub issueHi, my company has a rule that we mandatory set Content-Type: application.json; charset=utf-8
to all the request/response header. (I know the charset=utf-8
is probably redundant for json though.)
Since OpenAPI Validator drop charactors of Content-Type after the charactor of ;
as below, our OpenAPI Validator cannot find the appropriate request body schema and respond unsupported media type application/json
.
Sample api spec is described as below. Due to the issue above, requests which has Content-Type: application.json; charset=utf-8
cannot be associated with the schema $ref: '#/components/schemas/user'
.
paths:
/user/:userId:
post:
# --- skip ---
requestBody:
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/user'
# --- skip ---
I think we should use original raw value of Content-Type
in request header to find appropriate schema.
If you feel okay with my suggestion, let me create PR.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
fix available in
v2.15.1
@mk811 how are you making out? If u have any questions or want to discuss more freely, feel free to join us on gitter. https://gitter.im/cdimascio-oss/community