-
-
Notifications
You must be signed in to change notification settings - Fork 229
Description
The latest release (as of right now [email protected]
) does not validate the response if the response body does not contain JSON data (using res.send()
) and res.json()
is not explicitly called.
This is because the response validator hooks the res.json()
call (https://github.com/cdimascio/express-openapi-validator/blob/v5.5.3/src/middlewares/openapi.response.validator.ts#L56, and https://github.com/cdimascio/express-openapi-validator/blob/v5.5.3/src/framework/modded.express.mung.ts#L59) in order to do call the validation code.
When the response is, for example, an image (or any other non-JSON data) - the res.json()
is never called and the validation never occurs.
Thus, it is currently impossible to validate that the content-type and body of the response accurately matches what is defined in the response section of the OpenAPI document.
Would it be possible to hook the res.send()
call instead, so that these types of responses can also be validated?