How add value of 'title' dynamically.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022
10:39 AM
11-01-2022
10:39 AM
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)
);
};
Labels:
- Labels:
-
Test Setup
0 REPLIES 0
