[Nest.js] Swagger사용 방법
2021. 7. 30. 23:03ㆍNest.js
반응형
nest js 공식 문서에 OPEN API
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);
const config = new DocumentBuilder()
.setTitle('여기는 타이틀')
.setDescription('여기는 설명란')
.setVersion('2.3.4')
.addTag('여기는 태그')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('docs', app, document);
}
bootstrap();
이제 실행을 해보자.
npm run start:dev
SwaggerModule.setup('docs', app, document);
// 함수의 첫번째 파라미터가 엔드포인트가 된다.
이상 설정하는 방법이다.
반응형
'Nest.js' 카테고리의 다른 글
[nest.js] TypeORM 정리 (0) | 2021.08.24 |
---|---|
[Nest.js] nodemailer (0) | 2021.08.19 |
[Nest.js] redis 연동 (0) | 2021.08.10 |
[Nest.js] first step (0) | 2021.07.20 |