Expose a validate function that either throws err or return true
Is your feature request related to a problem? Please describe. I want to validate a req and then do certain steps. Dont want to use middleware directly.
Describe the solution you'd like Expose a validate function that validates request based on opneAPI spec and return true for success or throw error for failure
Additional context
Right now I am trying to achieve this by passing a custom callback in place of next() to
OpenApiValidator.middleware({
apiSpec: './openapi.yaml',
validateRequests: true, // (default)
validateResponses: true, // false by default
}),
and in callback if number of arguments is 0 then it means request is valid and if number of arguments is more that 0 then means its error state and capture and do the next step.
I came up with this by looking at the code of cdimascio/express-openapi-validator and noticed if pass next() gets called without any argument and if there is any error next(err) gets called with error.
But if you guys some day decided to change that pattern then our application will break. Hence I would like to request for a feature for this EDIT:
I decided to this by using multiple middlewares. Like using another middleware right after openapi validator and capture err and make decision then return error