Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : 스웨거 동적 예시값 생성 (#99) #101

Merged
merged 6 commits into from
Jan 12, 2023

Conversation

ImNM
Copy link
Member

@ImNM ImNM commented Jan 12, 2023

개요

요런걸 없앴슴니다

작업사항

  • 동적으로 스웨거 응답값 생성 하도록 지정했습니다.

  • 원래 예시값 적을때 json 형식으로 말도안되게 귀찮게 하는데 그런걸 없앴씁니다
    무제

  • api 하나마다 ( 적어주고싶은 중요한 에러가 있을시 )

@ExceptionDoc
public class ExampleExceptionDocs {

    @ExplainError("유저검색시에 안나올 때 나오는 에러입니다.")
    public DuDoongCodeException 유저없을때 = UserNotFoundException.EXCEPTION;

    @ExplainError("오더 낫파운드")
    public DuDoongCodeException 한글도된다 = OrderNotFoundException.EXCEPTION;

    @ExplainError("인밸리드 오더")
    public DuDoongCodeException 오류가났을때 = InvalidOrderException.EXCEPTION;
}
@GetMapping
    @DevelopOnlyApi
    @ApiErrorExample(ExampleExceptionDocs.class)
    public ExampleResponse get() {
        return exampleApiService.getExample();
    }

위와같은방법으로 ApiErrorExample 에 타입정도 넘기시면 자동으로 예시값 생성됩니다.
ExplainError 어노테이션으로 추가부가설명을 적을 수있습니다.
어떠어떠할때 오류가 생성된다~ 그런식으로 기술하면됩니다~

변경로직

  • 내용을 적어주세요.

@ImNM ImNM added For: Utils [이슈 대상] API, 모델, 뷰를 제외한 백엔드 로직 Type: Feature [이슈 목적] 새로운 기능 추가 labels Jan 12, 2023
@ImNM ImNM requested a review from sanbonai06 as a code owner January 12, 2023 10:40
@ImNM ImNM self-assigned this Jan 12, 2023
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 143 Code Smells

7.2% 7.2% Coverage
0.0% 0.0% Duplication

Copy link
Member

@cofls6581 cofls6581 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳굳 작업 공유 감사함둥 LGTM!

Copy link
Member

@sanbonai06 sanbonai06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ImNM ImNM merged commit 6f9d825 into dev Jan 12, 2023
@ImNM ImNM deleted the feature/99-swagger-dynamic-example-errorcode branch January 12, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For: Utils [이슈 대상] API, 모델, 뷰를 제외한 백엔드 로직 Type: Feature [이슈 목적] 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 [feature] 동적으로 스웨거 응답 예시값 생성 (에러 코드 기반)
3 participants