Swagger接口文档
安装依赖
npm install --save @nestjs/swagger swagger-ui-express使用
// main.ts
import { NestFactory } from "@nestjs/core";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import { AppModule } from "./app.module";
async function bootstrap() {
const app = await NestFactory.create(AppModule);
//swagger
const config = new DocumentBuilder()
.setTitle("Nest GO API Doc")
.setDescription("硬吃Nest.js")
.setVersion("1.0")
.addTag("Tag")
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup("doc", app, document);
await app.listen(3000);
console.log(`Application is running on: ${await app.getUrl()}`);
}
bootstrap();
自定义配置
配置装饰器
最后更新于