From d0a897de2c6f820ddf0456c5a2eb0692068e6020 Mon Sep 17 00:00:00 2001 From: kdomo Date: Tue, 25 Jul 2023 23:47:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[#15]=20chore:=20springdoc-openapi-ui=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TodaysFail-Interface/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/TodaysFail-Interface/build.gradle b/TodaysFail-Interface/build.gradle index d059bda..ea9162f 100644 --- a/TodaysFail-Interface/build.gradle +++ b/TodaysFail-Interface/build.gradle @@ -5,4 +5,5 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation('org.springdoc:springdoc-openapi-ui:1.6.15') } \ No newline at end of file From 132fd31b95773a4c960995297484bcb89537dafc Mon Sep 17 00:00:00 2001 From: kdomo Date: Tue, 25 Jul 2023 23:47:23 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[#15]=20chore:=20Swagger=20Config=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/swagger/SwaggerConfig.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java diff --git a/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java b/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java new file mode 100644 index 0000000..d08e481 --- /dev/null +++ b/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java @@ -0,0 +1,29 @@ +package com.todaysfail.config.swagger; + +import org.springframework.context.annotation.Bean; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; + +public class SwaggerConfig { + @Bean + public OpenAPI openAPI() { + Info info = new Info() + .title("오늘의 실패 API 문서") + .description("오늘의 실패 API 문서입니다.") + .version("v0.0.1"); + return new OpenAPI().info(info); + } + + private Info swaggerInfo() { + License license = new License(); + license.url("https://github.com/TodaysFail/TodaysFail-Backend"); + license.setName("TodaysFail"); + return new Info() + .title("TodaysFail API 문서") + .description("TodaysFail API 문서입니다.") + .version("v0.0.1") + .license(license); + } +} From 77079a2820daf3c2cea896bdf39d0f01afeb26b7 Mon Sep 17 00:00:00 2001 From: kdomo Date: Tue, 25 Jul 2023 23:47:59 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[#15]=20chore:=20Swagger=20default=20midia?= =?UTF-8?q?=20type=EA=B3=BC=20sort=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TodaysFail-Interface/src/main/resources/application.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TodaysFail-Interface/src/main/resources/application.yml b/TodaysFail-Interface/src/main/resources/application.yml index 361767d..24db2b7 100644 --- a/TodaysFail-Interface/src/main/resources/application.yml +++ b/TodaysFail-Interface/src/main/resources/application.yml @@ -3,6 +3,11 @@ spring: include: - infrastructure - domain +springdoc: + default-produces-media-type: application/json + default-consumes-media-type: application/json + swagger-ui: + tags-sorter: alpha --- spring: config: From 4497da39465d5909848ae3e982daf7463e26bb1d Mon Sep 17 00:00:00 2001 From: kdomo Date: Tue, 25 Jul 2023 23:48:14 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[#15]=20chore:=20Example=20Controller?= =?UTF-8?q?=EC=97=90=20Swagger=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/todaysfail/api/web/example/ExampleController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java index 32df9fa..27eb89b 100644 --- a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java +++ b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java @@ -3,12 +3,16 @@ import com.todaysfail.api.web.example.dto.response.ExampleResponse; import com.todaysfail.api.web.example.mapper.ExampleMapper; import com.todaysfail.example.usecase.ExampleReadUseCase; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "X. Example") @RestController @RequestMapping("/api/v1/examples") @RequiredArgsConstructor @@ -16,6 +20,7 @@ public class ExampleController { private final ExampleReadUseCase exampleReadUseCase; private final ExampleMapper exampleMapper; + @Operation(summary = "Example 조회 API") @GetMapping("/{example-id}") public ExampleResponse getExamples(@PathVariable("example-id") Long exampleId) { return exampleMapper.toResponse(exampleReadUseCase.execute(exampleId)); From a34bd08946ef9f39e0ae471672bc64fdf86d4e40 Mon Sep 17 00:00:00 2001 From: kdomo Date: Tue, 25 Jul 2023 23:49:22 +0900 Subject: [PATCH 5/5] [#15] style: spotless --- .../api/web/example/ExampleController.java | 1 - .../config/swagger/SwaggerConfig.java | 40 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java index 27eb89b..6c5d0c8 100644 --- a/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java +++ b/TodaysFail-Interface/src/main/java/com/todaysfail/api/web/example/ExampleController.java @@ -3,7 +3,6 @@ import com.todaysfail.api.web.example.dto.response.ExampleResponse; import com.todaysfail.api.web.example.mapper.ExampleMapper; import com.todaysfail.example.usecase.ExampleReadUseCase; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; diff --git a/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java b/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java index d08e481..6f1570c 100644 --- a/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java +++ b/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java @@ -1,29 +1,29 @@ package com.todaysfail.config.swagger; -import org.springframework.context.annotation.Bean; - import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; +import org.springframework.context.annotation.Bean; public class SwaggerConfig { - @Bean - public OpenAPI openAPI() { - Info info = new Info() - .title("오늘의 실패 API 문서") - .description("오늘의 실패 API 문서입니다.") - .version("v0.0.1"); - return new OpenAPI().info(info); - } + @Bean + public OpenAPI openAPI() { + Info info = + new Info() + .title("오늘의 실패 API 문서") + .description("오늘의 실패 API 문서입니다.") + .version("v0.0.1"); + return new OpenAPI().info(info); + } - private Info swaggerInfo() { - License license = new License(); - license.url("https://github.com/TodaysFail/TodaysFail-Backend"); - license.setName("TodaysFail"); - return new Info() - .title("TodaysFail API 문서") - .description("TodaysFail API 문서입니다.") - .version("v0.0.1") - .license(license); - } + private Info swaggerInfo() { + License license = new License(); + license.url("https://github.com/TodaysFail/TodaysFail-Backend"); + license.setName("TodaysFail"); + return new Info() + .title("TodaysFail API 문서") + .description("TodaysFail API 문서입니다.") + .version("v0.0.1") + .license(license); + } }