inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

Swagger 사용 관련 질문이 있습니다.

미해결

[리뉴얼] React로 NodeBird SNS 만들기

안녕하세요 제로초님! 제가 swagger를 이용해서 api들을 정리 및 테스트를 해볼려고 하는데 잘 되지가 않아서 질문드립니다. /** * @swagger * /user: * get: * tags: * description: 유저 데이터 조회 및 유저의 Post, Following, Follower 조회 * produces: * - application/json * parameters: * - in: user * name: id * description: 반드시 로그인이 되있는 상태에서 call 해야 user data 조회 가능 * schema: * type: object * properties: * name: * type: number * responses: * 200: * description: 유저 조회 성공 / 또는 조회 실패(null) */ router . get ( "/" , async ( req , res , next ) => { // GET /user try { if ( req . user ) { const fullUserWithoutPassword = await User . findOne ({ where : { id : req . user . id }, attributes : { exclude : [ "password" ], }, include : [ { model : Post , attributes : [ "id" ], }, { model : User , as : "Followings" , attributes : [ "id" ], }, { model : User , as : "Followers" , attributes : [ "id" ], }, ], }); res . status ( 200 ). json ( fullUserWithoutPassword ); } else { res . status ( 200 ). json ( null ); } } catch ( error ) { console . error ( error ); next ( error ); } }); 제가 get.axios("/user")를 swagger로 정리 및 테스트 할려고 하는데 계속 respond로 null이 뜹니다. 아무래도 제가 swagger 코드를 잘못친거 같은데 이 여기에서는 어떻게 swagger를 작성해야 될까요?

  • swagger
  • express
  • nodejs
  • react
  • redux
  • Next.js
현병익 댓글 1 좋아요 0 조회수 222

postman 응답 처럼 swagger 에서도 success 를 추가할수 없을까요?

해결됨

탄탄한 백엔드 NestJS, 기초부터 심화까지

export class ResultDto<T> { @ApiProperty() success: boolean; @ApiProperty() data: T } // ---- cats.controller.ts @ApiResponse({ type: ResultDto<ReadOnlyCatDto> }) @Post() async signUp(@Body() body: CatRequestDto) { return await this.catsService.signUp(body); } 이런 식으로 단순하고 typescript 의 제네릭으로 해봤는데 안되어 질문들입니다.

  • swagger
  • nodejs
  • ApiResponse
  • express
  • mongodb
  • NestJS
  • ssr
박정근 댓글 1 좋아요 3 조회수 982

swagger관련 질문있습니다

미해결

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

https://github.com/nestjs/swagger/issues/1006 여기있는 문제와 완전히 동일한 문제가생겨서 swagger문서가 나오지않고있습니다. 답변에 나온대로 헬멧 지워도보고 헬멧위로 올려도봤지만 계속 css와 js파일이 https로 불러와지고있습니다. 로컬환경에서는 문서가 잘 나오는데 ec2에 올리면 https로 불러와지네요.. 다른점이 찾기위해 로컬에 보내는 요청과 ec2에 보내는 요청을 비교해봤는데 로컬에서는 Referrer Policy가 strict-origin-when-cross-origin으로 설정되어있고 ec2에는 no-referrer로 설정되어있습니다. 혹시 이게 문제라면 어떤방식으로 접근하면 좋을지 조언 부탁드려도 될까요?

  • swagger
  • swagger-ui
  • nodejs
  • express
  • NestJS
  • TypeORM
강정우 댓글 2 좋아요 0 조회수 539

인기 태그

인프런 TOP Writers

주간 인기글