yarn add @nestjs/swagger swagger-ui-express
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.enableCors();
app.useStaticAssets('uploads', { prefix: '/uploads' });
const options = new DocumentBuilder()
.setTitle('Nodejs + Vuejs 全栈项目-后台管理API')
.setDescription('供后台管理界面调用的服务端API')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api-docs', app, document);
await app.listen(3000);
console.log('http://localhost:3000/api-docs');
}
bootstrap();
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200116165817214.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0JyYWR5Q0M=,size_16,color_FFFFFF,t_70)