From fc2e75af6ba8e000516b3d52b73cec9bb7a09d27 Mon Sep 17 00:00:00 2001 From: jini Date: Wed, 30 Nov 2022 16:50:31 +0900 Subject: [PATCH] =?UTF-8?q?:wrench:=20Swagger=20Config=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jiniworld/demohx/config/SwaggerConfig.kt | 41 +++++++++++++++++++ .../demohx/web/notice/GetNoticeController.kt | 3 -- 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 server/demo-app/src/main/kotlin/me/jiniworld/demohx/config/SwaggerConfig.kt diff --git a/server/demo-app/src/main/kotlin/me/jiniworld/demohx/config/SwaggerConfig.kt b/server/demo-app/src/main/kotlin/me/jiniworld/demohx/config/SwaggerConfig.kt new file mode 100644 index 0000000..9ff3449 --- /dev/null +++ b/server/demo-app/src/main/kotlin/me/jiniworld/demohx/config/SwaggerConfig.kt @@ -0,0 +1,41 @@ +package me.jiniworld.demohx.config + +import io.swagger.v3.oas.models.OpenAPI +import io.swagger.v3.oas.models.info.Contact +import io.swagger.v3.oas.models.info.Info +import io.swagger.v3.oas.models.info.License +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 + +@Configuration +class SwaggerConfig( + @Value("\${demo-app.version}") val version: String, + @Value("\${spring.profiles.active}") val profile: String, + @Value("\${demo-app.url}") val url: String, +) { + + @Bean + fun openAPI(): OpenAPI = + OpenAPI() +// .components( +// Components() +// .addSecuritySchemes("access_token", +// SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT") +// .`in`(SecurityScheme.In.HEADER).name("Authorization"))) +// .addSecurityItem(SecurityRequirement().addList("access_token")) + .info( + Info().title("demo-app API - $profile") + .description("Hexagonal Architecture 구조로 만든 코프링 웹 애플리케이션") + .contact(Contact().name("jini").url("https://blog.jiniworld.me/").email("jini@jiniworld.me")) + .license(License().name("MIT License").url("https://github.com/jiniya22/demo-hexagonal/blob/master/LICENSE"))) + .servers( + listOf( + Server().url(url).description( + "demo-app api ($profile)" + ) + ) + ) + +} \ No newline at end of file diff --git a/server/demo-app/src/main/kotlin/me/jiniworld/demohx/web/notice/GetNoticeController.kt b/server/demo-app/src/main/kotlin/me/jiniworld/demohx/web/notice/GetNoticeController.kt index 50f8a5e..16e14b1 100644 --- a/server/demo-app/src/main/kotlin/me/jiniworld/demohx/web/notice/GetNoticeController.kt +++ b/server/demo-app/src/main/kotlin/me/jiniworld/demohx/web/notice/GetNoticeController.kt @@ -5,11 +5,8 @@ import io.swagger.v3.oas.annotations.tags.Tag import me.jiniworld.demohx.annotation.WebAdapter import me.jiniworld.demohx.application.notice.port.input.GetNoticeQuery import me.jiniworld.demohx.application.notice.port.input.GetNoticesCommand -import me.jiniworld.demohx.model.BaseResponse import me.jiniworld.demohx.model.DataResponse import me.jiniworld.demohx.model.NotFoundException -import me.jiniworld.demohx.model.ServerException -import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* @WebAdapter