Dlise
시원한 냉장고
Dlise
전체 방문자
오늘
어제
  • 시원한 냉장고 (136)
    • Java (31)
      • Java (26)
      • Spring (5)
    • Algorithm & PS (25)
      • Algorithm (14)
      • Problem Solving (11)
    • Network (12)
    • Database (2)
    • Data Structure (4)
    • OOP & CleanCode (5)
    • Web (0)
    • Git (2)
    • AI (2)
    • Project (1)
      • Discord Bot (1)
    • Error (19)
    • Tools (5)
    • 수학 (5)
      • 확률과 통계(기초) (5)
    • 컴퓨터 구조 (3)
    • 활동 (20)
      • 행사 & 여행 (10)
      • 자격증 (4)
      • 회고 (6)
      • 기타 (0)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 통계학
  • 중위 표기법
  • CleanCode
  • 백준
  • spring security in action second edition
  • 가장쉬운알고리즘책
  • java
  • 열혈강의자료구조
  • 네트워크
  • 후위 표기법

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
Dlise

시원한 냉장고

Error

Spring - Swagger Response 정보가 보이지 않는 문제

2024. 7. 30. 15:59

코드 상에서 오류가 발생한 것은 아니지만 내용을 정리하고자 한다.

 

SpringBoot를 활용해 기능을 구현하던 중 API가 제대로 동작하는지 확인하기 위해 Swagger를 활용하였는데 어떤 API 내용은 정상적으로 보이는데 일부 API 내용이 보이지 않았다.

 

아래는 문제 코드와 사진이다.

    @Operation(summary = "사용자 조회", description = "특정 사용자 정보를 조회합니다.")
    @GetMapping("/profile")
    public ResponseEntity<?> getMemberProfile(Authentication authentication) {
        return ResponseEntity.status(HttpStatus.OK).body(memberService.getMemberProfile(authentication.getName()));
    }

 

해결 방법

반환 타입을 ResponseEntity<?>로 정의해 Swagger가 정확한 타입을 추론할 수 없는 것이 문제였다.

    @Operation(summary = "사용자 조회", description = "특정 사용자 정보를 조회합니다.")
    @GetMapping("/profile")
    public ResponseEntity<MemberProfileResponseDto> getMemberProfile(Authentication authentication) {
        return ResponseEntity.status(HttpStatus.OK).body(memberService.getMemberProfile(authentication.getName()));
    }

반환 타입을 특정하니 정상적으로 정보가 보였다.

'Error' 카테고리의 다른 글

MySQL - column ' ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by  (3) 2025.02.27
Spring - 406 Not Acceptable 발생  (0) 2024.08.05
Spring - 'Failed to convert from type [java.lang.String] to type [java.util.Date] for value [ ]'  (3) 2024.05.05
Chrome Vue.js devtools - Vue.js not detected  (0) 2024.05.03
Spring Tool Suite 4 - 'Installing Software' has encountered a problem. An internal error occurred during: "Installing Software"  (0) 2024.04.25
    'Error' 카테고리의 다른 글
    • MySQL - column ' ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
    • Spring - 406 Not Acceptable 발생
    • Spring - 'Failed to convert from type [java.lang.String] to type [java.util.Date] for value [ ]'
    • Chrome Vue.js devtools - Vue.js not detected
    Dlise
    Dlise

    티스토리툴바