express-openapi-validator
express-openapi-validator copied to clipboard
Call express-openapi-validator inside another middleware.
Call express-openapi-validator from another middleware.
When I configure express-openapi-validator as a call within another middleware. For example:
const myMiddleware = (req, res, next) => {
try {
OpenApiValidator.middleware({
apiSpec: './openapi.yaml',
validateRequests: true,
validateResponses: true,
}).map(m =>m(req, res, next)) // since it returns a OpenApiRequestHandler[]
} catch (err) {
next(err);
}
};
However the error is not passed to the next middleware and it is only printed to the console.
How to fix the above to call the validator inside another middleware?