guide

Once installed, define and initialize the SwaggerModule class in the main.ts file:

import { NestFactory } from '@nestjs/core'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); const config = new DocumentBuilder() .setTitle('Cats example') .setDescription('The cats API description') SetVersion (' 1.0 '). AddTag (' cats'). The build (); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); await app.listen(3000); } bootstrap();Copy the code

Go to http://localhost:3000/api you can see the Swagger interface.