installOperationHandlers called upon each request for each path and method
Describe the bug installOperationHandlers seems to be called on every iteration of the request resolving. This seems to be a lot of overhead
To Reproduce
I have implemented a custom resolver with the following signature which returns a resolve function:
export function netControllerResolver(handlersPath: string, route: RouteMetadata, apiDoc: any) : express.RequestHandler
I have configured it like so ` this.app.use(OpenApiValidator.middleware({ apiSpec: self.schema,
operationHandlers: {
basePath: path.join(__dirname, 'netcontrollers'),
resolver: netControllerResolver
},
.... ` Run a request against one interface,
Actual behavior I noticed that it loops over all of the pathes whenever I do a request, e.g. doing a cat-POST request will loop over the cat-POST and the dog-GET request
Expected behavior Either:
- The routes are resolved only once and remembered.
- Only the relevant route gets resolved
@einmalpizzafunghibitte I checked with resolver I've created and it works as expected: it is used only the first time and then, as it returns actual requestHandler and that handler is used after that.
In my case, resolver, being invoked only once, returns a closure as a request handler, and only that closure is called after that, theoretically, in IDE, that can look like entire resolver was called.
I was wrong. It remembers the routes. But still it iterates over ALL routes immdediately that leads to me having an issue, if one of the routes defined in openapi, is not defined in code. Which is clearly an error when this route is called. But not when I call another route. In general this is something that one will notice in development. So this is not a really big deal. But maybe some room for improvement :) Thank you very much for your reply. And good job!