Hello there 👋
I was wondering, how I could use this property (see title). I couldn't find any documentation about this.
I followed these instructions on the website: https://docs.nestjs.com/openapi/other-features#multiple-specifications
and I wanted to achieve following result: (look at the marked answer)
I tried the approach of the marked answer where I iterate an array with my modules I wanted to import.
Here is my code:
const modules: any[] = [CatsModule, DogsModule]
let i = 0;
const swaggerCustomOptions: ExpressSwaggerCustomOptions = {
urls: [],
};
// Import each module
for (const module of modules) {
const c = new DocumentBuilder()
.setTitle(`${module.name} API`)
.setDescription(`${module.name} API`)
.setVersion('1.0')
.setExternalDoc('YAML definition file', `/${globalPrefix + i}-yaml`)
.addTag(module.name)
.build();
const d = SwaggerModule.createDocument(app, c, {
include: [module]
});
SwaggerModule.setup(globalPrefix + i, app, d, {
url: `/${globalPrefix + i}-yaml`
});
i++;
swaggerCustomOptions.urls.push({
name: module.name,
url: `http://localhost:4400/${globalPrefix + i}-yaml`
})
}
// root-path
const config = new DocumentBuilder()
.setTitle(`${AppModule.name} API`)
.setDescription(`${AppModule.name} API`)
.setVersion('1.0')
.setExternalDoc('YAML definition file', `/${globalPrefix}-yaml`)
.build();
const document = SwaggerModule.createDocument(app, config, {
include: [AppModule]
});
swaggerCustomOptions.urls.push({
name: AppModule.name,
url: `http://localhost:4400/${globalPrefix}-yaml`
})
swaggerCustomOptions.url = globalPrefix;
SwaggerModule.setup(globalPrefix, app, document, swaggerCustomOptions);
Unfortunately it doesn't work. (no selection available)
Any help is appreciated. Thanks in advance
I saw in the swagger ui documentation that you can provide a urls parameter which is:
An array of API definition objects ({url: "", name: ""}) used by Topbar plugin. When used and Topbar plugin is
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Progamming), FP (Functional Programming), and FRP (Functional Reactive Programming).