Andrey-Yur
3 years agoRegular Visitor
How add value of 'title' dynamically.
I'm using OpenAPI Object for launch the Swagger hub in our app. We have several routes were described by the Swagger JsDoc. I built a hub with links to the each controller with routes. Each controller has name which I would like put as `title` of `info ` field in the Shema obj. So, how can I put in that `title` value dynamically , or access to the OpenAPI Object? Can I put function like : title: ()=>{ ...} ?
const routesOptions = {
swaggerDefinition: {
openapi: '3.0.3',
info: {
title: 'Route',
version: '2.0'
},
servers: [
{
}
],
components: {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT'
}
}
},
security: [
{
bearerAuth: []
}
]
}
};
const mapRoutes = function (app) {
const options = {
...routesOptions,
apis: [ './api/map/*.js']
};
const swaggerSpec = swaggerJSDoc(options);
app.use(
'/docs/map-routes',
swaggerUi.serveFiles(swaggerSpec),
swaggerUi.setup(swaggerSpec)
);
};