diff --git a/Dockerfile b/Dockerfile index 20440ae..b9fb4a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ FROM openjdk:17-alpine CMD ["./gradlew", "clean", "build"] ARG JAR_FILE_PATH=build/libs/devrace-backend-0.0.1-SNAPSHOT.jar COPY ${JAR_FILE_PATH} app.jar -ENTRYPOINT ["java", "-Dspring.profiles.active=prod,swagger,mongodb,oauth,bucket", "-jar", "app.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-Dspring.profiles.active=prod,secret", "-jar", "app.jar"] \ No newline at end of file diff --git a/src/main/java/com/sajang/devracebackend/config/AwsS3Config.java b/src/main/java/com/sajang/devracebackend/config/AwsS3Config.java index 27a71a2..6416441 100644 --- a/src/main/java/com/sajang/devracebackend/config/AwsS3Config.java +++ b/src/main/java/com/sajang/devracebackend/config/AwsS3Config.java @@ -21,6 +21,7 @@ public class AwsS3Config { @Value("${cloud.aws.region.static}") private String region; + @Bean public AmazonS3Client amazonS3Client() { AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); diff --git a/src/main/java/com/sajang/devracebackend/config/SwaggerConfig.java b/src/main/java/com/sajang/devracebackend/config/SwaggerConfig.java index 81a5727..e7ac7d0 100644 --- a/src/main/java/com/sajang/devracebackend/config/SwaggerConfig.java +++ b/src/main/java/com/sajang/devracebackend/config/SwaggerConfig.java @@ -6,17 +6,24 @@ import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.servers.Server; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.Arrays; +import java.util.List; @Configuration public class SwaggerConfig { + @Value("${server.env}") + private String serverEnv; + @Value("${server.url}") + private String serverUrl; + + @Bean public OpenAPI openAPI() { - String authName = "JWT"; // 기능 타이틀명 SecurityRequirement securityRequirement = new SecurityRequirement().addList(authName); @@ -31,18 +38,11 @@ public OpenAPI openAPI() { .description("'Bearer '을 제외한 Access Token 입력하세요.") ); - Server localServer = new Server(); - localServer.description("Http local server") - .url("http://localhost:8080"); - Server prodServer = new Server(); - prodServer.description("Https prod server") - .url("https://www.dev-race.site"); - return new OpenAPI() .addSecurityItem(securityRequirement) .components(components) .info(apiInfo()) - .servers(Arrays.asList(prodServer, localServer)); + .servers(apiServer()); } private Info apiInfo() { @@ -51,4 +51,15 @@ private Info apiInfo() { .description("Rest API 명세서 / WebSocket API 명세서") .version("1.0.0"); } + + private List apiServer() { + String description = "Local Server"; + if(serverEnv.equals("prod")) description = "Prod Server"; + + Server server = new Server() + .description(description) + .url(serverUrl); + + return Arrays.asList(server); + } } diff --git a/src/main/java/com/sajang/devracebackend/service/impl/UserServiceImpl.java b/src/main/java/com/sajang/devracebackend/service/impl/UserServiceImpl.java index f07a55a..76acbd4 100644 --- a/src/main/java/com/sajang/devracebackend/service/impl/UserServiceImpl.java +++ b/src/main/java/com/sajang/devracebackend/service/impl/UserServiceImpl.java @@ -140,7 +140,7 @@ public static UserSolvedResponseDto getSolvedCount(String bojId) { // WebClient .bodyToMono(UserSolvedResponseDto.class) .block(); } catch (Exception e){ - throw new Exception404.NoSuchBojId(String.format("bojId = %d", bojId)); // solvedac 서버에 존재하지않는 백준id일경우 예외 처리. + throw new Exception404.NoSuchBojId("bojId = " + bojId); // solvedac 서버에 존재하지않는 백준id일경우 예외 처리. } } } \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 1cfddaf..1f4a21d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,4 +8,20 @@ spring.mvc.pathmatch.matching-strategy=ant_path_matcher spring.servlet.multipart.maxFileSize=30MB spring.servlet.multipart.maxRequestSize=30MB -spring.profiles.active=local,swagger,mongodb,oauth,bucket \ No newline at end of file +## Swagger +springdoc.packages-to-scan=com.sajang.devracebackend.controller +springdoc.default-consumes-media-type=application/json;charset=UTF-8 +springdoc.default-produces-media-type=application/json;charset=UTF-8 +# URI + /swagger +springdoc.swagger-ui.path=/swagger +springdoc.swagger-ui.disable-swagger-default-url=true +springdoc.writer-with-default-pretty-printer=true +# true: show Checking API response time +springdoc.swagger-ui.display-request-duration=false +# alpha: sort by Alphabet, method: sort by HTTP status code +springdoc.swagger-ui.operations-sorter=alpha +# Disabled to cause 'Test' Tag to go down. +# springdoc.swagger-ui.tags-sorter=alpha + +## Profile +spring.profiles.active=local,secret \ No newline at end of file diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 61513bb..28fcc51 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -5,7 +5,10 @@ OAuth2 Test html - Google Login
- Github Login
+


+
+

Google Login

+

Github Login

+
- \ No newline at end of file + diff --git a/submodule-backend b/submodule-backend index 5ac056d..e1596e7 160000 --- a/submodule-backend +++ b/submodule-backend @@ -1 +1 @@ -Subproject commit 5ac056d7925d6476da4bb98fcfd8038355d0c4f3 +Subproject commit e1596e768a6a775d212397add4c5b7f847ebd368