From 94cc1c2dc206d354168b886de5700e5b4e25da73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=AA=85=EB=8D=95?= <68066437+Profile-exe@users.noreply.github.com> Date: Tue, 19 Nov 2024 21:29:55 +0900 Subject: [PATCH] =?UTF-8?q?[DOCS]=20MemberToken=20=EC=A3=BC=EC=9E=85=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20Swagger=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=95=88=EB=B3=B4=EC=9D=B4=EA=B2=8C=20=EC=88=98=EC=A0=95=20(#2?= =?UTF-8?q?03)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: MemberToken을 Swagger에서 숨 * refactor: NonNull 어노테이션 추가 --- .../buddybridge/auth/controller/AuthController.java | 3 ++- .../buddybridge/auth/controller/OAuthController.java | 3 ++- .../common/exception/GlobalExceptionHandler.java | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/econo/buddybridge/auth/controller/AuthController.java b/src/main/java/econo/buddybridge/auth/controller/AuthController.java index fbfb98f..8f2415d 100644 --- a/src/main/java/econo/buddybridge/auth/controller/AuthController.java +++ b/src/main/java/econo/buddybridge/auth/controller/AuthController.java @@ -11,6 +11,7 @@ import econo.buddybridge.utils.api.ApiResponse.CustomBody; import econo.buddybridge.utils.api.ApiResponseGenerator; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -50,7 +51,7 @@ public ApiResponse> login( @Operation(summary = "Access Token, Refresh Token 재발급", description = "Refresh Token을 이용해 Access Token과 Refresh Token을 재발급합니다.") @PostMapping("/reissue") - public ApiResponse> reissue(@MemberToken String token) { + public ApiResponse> reissue(@Parameter(hidden = true) @MemberToken String token) { AuthToken authToken = authService.reissue(token); return ApiResponseGenerator.success(authToken, HttpStatus.OK); } diff --git a/src/main/java/econo/buddybridge/auth/controller/OAuthController.java b/src/main/java/econo/buddybridge/auth/controller/OAuthController.java index 4c2edc1..b03305e 100644 --- a/src/main/java/econo/buddybridge/auth/controller/OAuthController.java +++ b/src/main/java/econo/buddybridge/auth/controller/OAuthController.java @@ -12,6 +12,7 @@ import econo.buddybridge.utils.api.ApiResponse.CustomBody; import econo.buddybridge.utils.api.ApiResponseGenerator; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; @@ -93,7 +94,7 @@ public ApiResponse> loginWithToken(@RequestBody KakaoLogin // refresh token 재발급 @Operation(summary = "Access Token, Refresh Token 재발급", description = "Refresh Token을 이용하여 두 토큰 모두 재발급합니다.") @PostMapping("/reissue") - public ApiResponse> reissue(@MemberToken String token) { + public ApiResponse> reissue(@Parameter(hidden = true) @MemberToken String token) { AuthToken authToken = oAuthLoginService.reissue(token); return ApiResponseGenerator.success(authToken, HttpStatus.OK); } diff --git a/src/main/java/econo/buddybridge/common/exception/GlobalExceptionHandler.java b/src/main/java/econo/buddybridge/common/exception/GlobalExceptionHandler.java index fbb1521..12d7ff1 100644 --- a/src/main/java/econo/buddybridge/common/exception/GlobalExceptionHandler.java +++ b/src/main/java/econo/buddybridge/common/exception/GlobalExceptionHandler.java @@ -6,6 +6,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; +import org.springframework.lang.NonNull; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -24,13 +25,13 @@ public ApiResponse> handleBusinessException(BusinessEx @Override protected ResponseEntity handleMethodArgumentNotValid( // 파라미터 유효성 검사 실패 시 발생하는 예외 처리 - MethodArgumentNotValidException ex, - HttpHeaders headers, - HttpStatusCode status, - WebRequest request + @NonNull MethodArgumentNotValidException ex, + @NonNull HttpHeaders headers, + @NonNull HttpStatusCode status, + @NonNull WebRequest request ) { // 공통 에러 코드로 처리 - // 세부 검증 오류는 ErrorResponse.invalidParams에 담아서 반환 + // 세부 검증 오류는 ErrorResponse#invalidParams에 담아서 반환 ErrorCode errorCode = CommonErrorCode.INVALID_INPUT_VALUE; return ResponseEntity.status(errorCode.getHttpStatus())