HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
SFAM 포트폴리오
SFAM 포트폴리오
/
❗
Custom @AuthenticationPrincipal 스웨거 명세되는 문제
❗

Custom @AuthenticationPrincipal 스웨거 명세되는 문제

식별

@AuthenticationPrincipal을 커스텀한 @AuthUser 어노테이션을 추가하고 사용한 후 스웨거 명세에 @AuthUser 객체가 명세되는 문제가 발생했습니다.
 
notion image
 

분석 및 개선 방향

Swagger의 기본 설정에는 @AuthenticationPrincipal 이라는 어노테이션을 기본적으로 Ignore하는 설정을 갖고 있었습니다.
notion image
하지만 새로만든 @AuthUser어노테이션은 Ignore 설정이 되지 않았기 때문으로 파악되었습니다. 새로만든 @AuthUser 어노테이션도 @AuthenticationPrincipal 처럼 Ignore 되도록 설정해주면 해결될 것 같았습니다.

해결

다음과 같은 설정을 추가해서 해결할 수 있었습니다.
notion image