-
-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Description
Describe the bug
In the example given for custom operation resolver, we can read:
new OpenApiValidator({
apiSpec,
operationHandlers: {
basePath: path.join(__dirname, 'routes'),
resolver: (basePath, route) => {
// Pluck controller and function names from operationId
const [controllerName, functionName] = route.schema['operationId'].split('.')
// Get path to module and attempt to require it
const modulePath = path.join(basePath, controllerName);
const handler = require(modulePath)
// Simplistic error checking to make sure the function actually exists
// on the handler module
if (handler[functionName] === undefined) {
throw new Error(
`Could not find a [${functionName}] function in ${modulePath} when trying to route [${route.method} ${route.expressRoute}].`
)
}
// Finally return our function
return handler[functionName]
}
});
So route is supposed to have a schema
property.
We can only access:
{
basePath: "..."
expressRoute: "..."
method: "GET"
openApiRoute: "..."
pathParams: []
}
Instead resolver has 3 arguments : basePath
(which is the baseDirectory, not route.basePath), route
AND apiDoc
!
The example should mention apiDoc
instead of route.schema
.
Metadata
Metadata
Assignees
Labels
No labels