前文参考:
1. 安装swagger
npm i @nestjs/swagger
2. main.ts加入swagger
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const swaggerOptions = new DocumentBuilder()
.setTitle('nest-starter api document')
.setDescription('nest starter project api document')
.setVersion('1.0')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, swaggerOptions);
SwaggerModule.setup('doc', app, document);
await app.listen(3000);
}
bootstrap();
3. 验证
4. 增加标签及说明
验证: