티스토리 뷰
nest api 서버 개발 프로젝트
[nestjs/swagger] nestjs에서 간단하게 swagger를 활용한 document(문서) 자동화 [API 실행 / 테스트 / 파라미터 ] 3/3
개발자 고포고 2021. 11. 18. 00:29반응형
[nestjs/swagger] nestjs에서 간단하게 swagger를 활용한 document(문서) 자동화 [API 실행 / 테스트 / 파라미터 ] 3/3
@Controller('beacon')
@ApiTags('비콘 API')
export class BeaconController {
constructor(private readonly service: BeaconService) {}
@Post()
@ApiOperation({ summary: '등록', description: '정보를 등록한다.' })
@ApiCreatedResponse({
description: '등록',
type: tb_beacon,
})
@ApiBody({ type: tb_beacon })
async create(@Body() createDto: ICreateBeaconDto) {
const returnValue = await this.service.create(createDto);
return returnValue;
}
}
@ApiCreatedResponse - 생성 완료를 알리는 status code 201에 대한 설정
-description : 설명을 기록한다
-type: entity 객체명을 기록한다.
@ApiBody - 파라미터 형식을 기록한다.
* dto가 class 형태라면 dto형식을 입력하고, dto가 interface형태라면 entity 객체명을 입력하여주자.
손쉽게 post 샘플 테스트가 진행가능한 형태가 된다.
#nestjs #swagger #swaggerUI #문서화 #문서자동화 #api #api 문서화 #api 문서 자동화 #swagger 문서 자동화
#ApiCreatedResponse #ApiBody
반응형
'nest api 서버 개발 프로젝트' 카테고리의 다른 글
댓글
반응형