-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Chore : .gitignore * Feat : Swagger Config 구현 * Feat : Swagger interface 로 분리 * Feat : build.gradle 변경 * Feat : Swagger 경로 추가 및 기존 테스트 제거 * Faet : 표기 방식 설정
- Loading branch information
Showing
10 changed files
with
245 additions
and
206 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,5 +59,5 @@ replay_pid* | |
./gradle | ||
/out | ||
/secret | ||
/.gradle | ||
/.gradle/ | ||
/.gradle |
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/donkeys_today/server/presentation/api/UserController.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,49 @@ | ||
package com.donkeys_today.server.presentation.api; | ||
|
||
import com.donkeys_today.server.common.constants.Constants; | ||
import com.donkeys_today.server.presentation.user.dto.requset.UserSignInRequest; | ||
import com.donkeys_today.server.presentation.user.dto.requset.UserSignUpRequest; | ||
import com.donkeys_today.server.presentation.user.dto.response.UserSignInResponse; | ||
import com.donkeys_today.server.presentation.user.dto.response.UserSignUpResponse; | ||
import com.donkeys_today.server.support.dto.ApiResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "인증/인가") | ||
@RequestMapping("/api/v1") | ||
@RestController | ||
public interface UserController { | ||
|
||
@Operation(summary = "유저 회원가입 ", description = "Authorization code 와 UserSignUpRequest 로 회원가입을 진행합니다.") | ||
@PostMapping("/auth/signup") | ||
ResponseEntity<ApiResponse<UserSignUpResponse>> signUp( | ||
@RequestHeader(Constants.AUTHORIZATION) @Parameter(name = "Authorization", description = "클라이언트가 인증 서버로부터 받은 인증 코드", required = true) final String auth_code, | ||
@RequestBody( | ||
description = "회원가입을 위하여 부가적으로 받는 정보 객체", | ||
required = true, | ||
content = @Content(schema = @Schema(implementation = UserSignUpRequest.class)) | ||
) final UserSignUpRequest request | ||
); | ||
|
||
@Operation(summary = "유저 로그인 ", description = "Authorization code로 로그인을 진행합니다.") | ||
@PostMapping("/auth/signin") | ||
ResponseEntity<ApiResponse<UserSignInResponse>> signIn( | ||
@RequestHeader(Constants.AUTHORIZATION) @Parameter(name = "Authorization", description = "클라이언트가 인증 서버로부터 받은 인증 코드", required = true) final String auth_code, | ||
@RequestBody( | ||
description = "로그인을 위하여 부가적으로 받는 정보 객체", | ||
required = true, | ||
content = @Content(schema = @Schema(implementation = UserSignInRequest.class)) | ||
) final UserSignInRequest userSignInRequest | ||
); | ||
|
||
|
||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/java/com/donkeys_today/server/presentation/user/dto/requset/UserSignInRequest.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
2 changes: 2 additions & 0 deletions
2
src/main/java/com/donkeys_today/server/presentation/user/dto/requset/UserSignUpRequest.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
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/donkeys_today/server/support/swagger/config/SwaggerConfig.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,35 @@ | ||
package com.donkeys_today.server.support.swagger.config; | ||
|
||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public OpenAPI customOpenAPI(){ | ||
String jwt = "JWT"; | ||
SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwt); | ||
Components components = new Components().addSecuritySchemes(jwt, new SecurityScheme() | ||
.name(jwt) | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT") | ||
); | ||
return new OpenAPI() | ||
.components(new Components()) | ||
.info(apiInfo()); | ||
} | ||
|
||
private Info apiInfo(){ | ||
return new Info() | ||
.title("Clody API 문서") | ||
.description("Clody API ") | ||
.version("1.0"); | ||
} | ||
} |
58 changes: 29 additions & 29 deletions
58
src/test/java/com/donkeys_today/server/docs/RestDocsSupport.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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package com.donkeys_today.server.docs; | ||
|
||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.restassured.module.mockmvc.RestAssuredMockMvc; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.restdocs.RestDocumentationContextProvider; | ||
import org.springframework.restdocs.RestDocumentationExtension; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
|
||
@ExtendWith(RestDocumentationExtension.class) | ||
public abstract class RestDocsSupport { | ||
|
||
protected MockMvc mockMvc; | ||
protected ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
@BeforeEach | ||
public void setUp(RestDocumentationContextProvider provider) throws Exception { | ||
this.mockMvc = MockMvcBuilders.standaloneSetup(initController()) | ||
.apply(documentationConfiguration(provider)) | ||
.build(); | ||
RestAssuredMockMvc.mockMvc(this.mockMvc); | ||
} | ||
|
||
protected abstract Object initController() throws Exception; | ||
} | ||
//package com.donkeys_today.server.docs; | ||
// | ||
//import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; | ||
// | ||
//import com.fasterxml.jackson.databind.ObjectMapper; | ||
//import io.restassured.module.mockmvc.RestAssuredMockMvc; | ||
//import org.junit.jupiter.api.BeforeEach; | ||
//import org.junit.jupiter.api.extension.ExtendWith; | ||
//import org.springframework.restdocs.RestDocumentationContextProvider; | ||
//import org.springframework.restdocs.RestDocumentationExtension; | ||
//import org.springframework.test.web.servlet.MockMvc; | ||
//import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
// | ||
//@ExtendWith(RestDocumentationExtension.class) | ||
//public abstract class RestDocsSupport { | ||
// | ||
// protected MockMvc mockMvc; | ||
// protected ObjectMapper objectMapper = new ObjectMapper(); | ||
// | ||
// @BeforeEach | ||
// public void setUp(RestDocumentationContextProvider provider) throws Exception { | ||
// this.mockMvc = MockMvcBuilders.standaloneSetup(initController()) | ||
// .apply(documentationConfiguration(provider)) | ||
// .build(); | ||
// RestAssuredMockMvc.mockMvc(this.mockMvc); | ||
// } | ||
// | ||
// protected abstract Object initController() throws Exception; | ||
//} |
Oops, something went wrong.