Is your feature request related to a problem? Please describe.
I am using express-openapi-validator with the validateSecurity and operationHandlers options. In validateSecurity, I pass functions that decode the JWT token, validate it, and add information from the token payload to req. In operationHandlers, I specify the path to the files where functions with the same names as those defined in operationId in the openapi.yaml file are located.
I am trying to figure out how to add middleware that applies after the validateSecurity functions but before the operationHandlers, which route the requests. However, it seems that this is not possible. The only workaround I can see is passing a resolver function in OperationHandlerOptions, but this feels like a hack. This approach combines two separate concerns—route creation and middleware application into one concrete route, making it less intuitive.
Describe the solution you'd like
It would be great if there were an optional parameter, something like postAuthMiddlewares or postValidateSecurityMiddlewares, which would accept an array of RequestHandler and be applied after validateSecurity but before the routing stage handled by operationHandlers.
Describe alternatives you've considered
Additional context
express-openapi-validator version: 5
Is your feature request related to a problem? Please describe.
I am using
express-openapi-validatorwith thevalidateSecurityandoperationHandlersoptions. InvalidateSecurity, I pass functions that decode the JWT token, validate it, and add information from the token payload toreq. InoperationHandlers, I specify the path to the files where functions with the same names as those defined inoperationIdin theopenapi.yamlfile are located.I am trying to figure out how to add middleware that applies after the
validateSecurityfunctions but before theoperationHandlers, which route the requests. However, it seems that this is not possible. The only workaround I can see is passing aresolverfunction inOperationHandlerOptions, but this feels like a hack. This approach combines two separate concerns—route creation and middleware application into one concrete route, making it less intuitive.Describe the solution you'd like
It would be great if there were an optional parameter, something like
postAuthMiddlewaresorpostValidateSecurityMiddlewares, which would accept an array ofRequestHandlerand be applied aftervalidateSecuritybut before the routing stage handled byoperationHandlers.Describe alternatives you've considered
Additional context
express-openapi-validator version: 5