Given payload validation is turned on for incoming requests and a requestBody defining content of application/json in the openapi spec
When a request is made with a Content-Type of application/json; charset=utf-8Expectation:
Then the request is validated against the defined application/json content spec
Actual:
Then the request is not validated
In this scenario, mediaType will be equal to application/json;charset=UTF-8 but content only has a mapping for application/json, thus media becomes null and validation is subsequently skipped.
Given payload validation is turned on for incoming requests and a
requestBody
definingcontent
ofapplication/json
in the openapi spec When a request is made with aContent-Type
ofapplication/json; charset=utf-8
Expectation: Then the request is validated against the defined application/json content spec Actual: Then the request is not validatedThis appears to be due to the request's content-type being used as a key for getting the appropriate media from the Content Map at: https://github.com/swagger-api/swagger-inflector/blob/afdbac64fc58f42f3b22c7187602b70231065fa0/src/main/java/io/swagger/oas/inflector/controllers/OpenAPIOperationController.java#L353
In this scenario,
mediaType
will be equal toapplication/json;charset=UTF-8
butcontent
only has a mapping forapplication/json
, thusmedia
becomesnull
and validation is subsequently skipped.Using swagger-inflector:2.0.8