-
Notifications
You must be signed in to change notification settings - Fork 1
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
[REFACTOR] swagger 관련 코드 controller에서 분리 #141
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ba627ce
feat : swagger 관련 설정 openApi로 변경
kssumin 254b5a2
refactor : swagger 코드 interface로 분리
kssumin 9aec74d
chore : 사용하지 않는 메서드 제거
kssumin 157731c
chore : test환경 yml 제거
kssumin 81fd628
chore : 통과하지 않는 테스트 임시적으로 주석 처리
kssumin c29d00a
chore : 사용하지 않는 fake 객체 제거
kssumin ac05135
refactor : 게스트 권한을 관리하는 객체 model로 위치 변경
kssumin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
eeos/src/main/java/com/blackcompany/eeos/auth/presentation/docs/AuthApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.blackcompany.eeos.auth.presentation.docs; | ||
|
||
import com.blackcompany.eeos.auth.application.dto.request.EEOSLoginRequest; | ||
import com.blackcompany.eeos.auth.application.dto.response.TokenResponse; | ||
import com.blackcompany.eeos.auth.presentation.support.Member; | ||
import com.blackcompany.eeos.common.presentation.respnose.ApiResponse; | ||
import com.blackcompany.eeos.common.presentation.respnose.ApiResponseBody.SuccessBody; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
@Tag(name = "인증", description = "인증 관련 API") | ||
public interface AuthApi { | ||
@Operation( | ||
summary = "OAuth 로그인", | ||
description = "PathVariable에 담긴 redirect_url, code를 받아 액세스 토큰과 리프레시 토큰을 발급한다.") | ||
ApiResponse<SuccessBody<TokenResponse>> login( | ||
@Parameter(description = "OAuth 서버 타입 (예: slack)", required = true) @PathVariable | ||
String oauthServerType, | ||
@Parameter(description = "OAuth 인증 코드", required = true) @RequestParam("code") String code, | ||
@Parameter(description = "리다이렉트 URI", required = true) @RequestParam("redirect_uri") | ||
String uri, | ||
HttpServletResponse httpResponse); | ||
|
||
@Operation(summary = "일반 로그인", description = "사용자가 id와 password를 이용하여 로그인한다.") | ||
ApiResponse<SuccessBody<TokenResponse>> login( | ||
@Parameter(description = "로그인 요청 정보", required = true) @RequestBody EEOSLoginRequest request, | ||
HttpServletResponse httpResponse); | ||
|
||
@Operation( | ||
summary = "토큰 재발급", | ||
description = "쿠키에 담긴 사용자 토큰을 이용하여 리프레시 토큰을 반환한다.", | ||
security = @SecurityRequirement(name = "bearerAuth")) | ||
ApiResponse<SuccessBody<TokenResponse>> reissue( | ||
HttpServletRequest request, HttpServletResponse httpResponse); | ||
|
||
@Operation( | ||
summary = "로그아웃", | ||
description = "쿠키에 담긴 리프레시 토큰을 이용하여 로그아웃한다.", | ||
security = @SecurityRequirement(name = "bearerAuth")) | ||
ApiResponse<SuccessBody<Void>> logout( | ||
HttpServletRequest request, | ||
HttpServletResponse httpResponse, | ||
@Parameter(hidden = true) @Member Long memberId); | ||
|
||
@Operation( | ||
summary = "회원탈퇴", | ||
description = "쿠키에 담긴 리프레시 토큰을 이용하여 회원을 탈퇴한다.", | ||
security = @SecurityRequirement(name = "bearerAuth")) | ||
ApiResponse<SuccessBody<Void>> withDraw( | ||
HttpServletRequest request, | ||
HttpServletResponse httpResponse, | ||
@Parameter(hidden = true) @Member Long memberId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
eeos/src/main/java/com/blackcompany/eeos/comment/presentation/docs/CommentApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.blackcompany.eeos.comment.presentation.docs; | ||
|
||
import com.blackcompany.eeos.comment.application.dto.*; | ||
import com.blackcompany.eeos.common.presentation.respnose.ApiResponse; | ||
import com.blackcompany.eeos.common.presentation.respnose.ApiResponseBody.*; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@Tag(name = "질문 및 댓글", description = "댓글 및 질문 관련 API") | ||
public interface CommentApi { | ||
|
||
@Operation(summary = "질문 및 코멘트 작성", description = "코멘트 및 질문을 생성합니다.") | ||
ApiResponse<SuccessBody<CommandCommentResponse>> create( | ||
@Parameter(hidden = true) Long memberId, @RequestBody CreateCommentRequest request); | ||
|
||
@Operation(summary = "질문 및 코멘트 수정", description = "코멘트 및 질문을 수정합니다.") | ||
ApiResponse<SuccessBody<CommandCommentResponse>> update( | ||
@Parameter(hidden = true) Long memberId, | ||
@PathVariable("commentId") Long commentId, | ||
@RequestBody UpdateCommentRequest request); | ||
|
||
@Operation(summary = "질문 및 코멘트 삭제", description = "코멘트 및 질문을 삭제합니다.") | ||
ApiResponse<SuccessBody<Void>> delete( | ||
@Parameter(hidden = true) Long memberId, @PathVariable("commentId") Long commentId); | ||
|
||
@Operation(summary = "질문 및 코멘트 조회", description = "코멘트 및 질문을 조회합니다.") | ||
ApiResponse<SuccessBody<QueryCommentsResponse>> getComments( | ||
@Parameter(hidden = true) Long memberId, | ||
@RequestParam("programId") Long programId, | ||
@RequestParam("teamId") Long teamId); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이전에 Slack으로 보내주신 사진을 보면, RequestMapping과 PathVariable, RequestParam도 모두 Interface로 빼놓았는데, 지금은 안 빼놓으신 이유가 Controller 메소드 코드를 봤을 때, 어떻게 동작하는지 바로 알 수 있게 하기 위함인가요?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵!! 맞아요!!
RequestMapping과 PathVariable, RequestParam은 web에 의존적인 것이라고 판단했어요!!
swagger가 아닌 다른 문서로 변경되었을 때 web 코드가 변경되어야 하는가?
만약 추후 swagger가 아닌 다른 문서로 변경이 된다고 했을 때 RequestMapping과 PathVariable, RequestParam와 같은 web 계층의 변화는 없어야 한다고 생각했어요.
해당 라이브러리들의 패키지를 기준
package org.springframework.web.bind.annotation;
패키지에 속한다.package io.swagger.v3.oas.annotations;
에 속한다.이러한 패키지의 위치를 기준으로 interface로 나누었습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 그렇네요 Swagger에 Web 어노테이션을 붙이면, Web 어노테이션이 Swagger와 공존해서, 의존성이 생겨버리니까 분리를 한 거군요! 이해됐습니다! 감사합니다!