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 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..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,12 +3,15 @@ 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 +19,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)); 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..6f1570c --- /dev/null +++ b/TodaysFail-Interface/src/main/java/com/todaysfail/config/swagger/SwaggerConfig.java @@ -0,0 +1,29 @@ +package com.todaysfail.config.swagger; + +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); + } + + 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); + } +} 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: