Expose your OpenApi spec on your API using the powerful Swagger UI interface.
The Swagger UI module provides a simple implementation of the @nestjs/swagger module.
Using this module, you can register the Swagger UI just like a normal module to reduce the amount of boilerplate in your main.ts.
yarn add @concepta/nestjs-swagger-ui
app.module.ts
@Module({
imports: [
SwaggerUiModule.register({
settings: {
path: 'api',
basePath: '/v1',
},
}),
],
})
export class AppModule {}
main.ts
async function bootstrap() {
// create app
const app = await NestFactory.create(AppModule);
// get the swagger ui service
const swaggerUiService = app.get(SwaggerUiService);
// set it up
swaggerUiService.setup(app);
// start listening
await app.listen(3000);
}
bootstrap();
All of the options in the official docs for NestJS OpenApi are supported.
To see how they are mapped to the registration options settings
property,
see the SwaggerUiSettingsInterface