From ae69ffe8884a545647552001fc280fd989fea7fc Mon Sep 17 00:00:00 2001 From: tlarbals824 Date: Fri, 1 Mar 2024 17:39:25 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=86=A0=ED=81=B0=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kobaco/infra/config/SwaggerConfig.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 kobaco/kobaco/src/main/java/core/kobaco/infra/config/SwaggerConfig.java diff --git a/kobaco/kobaco/src/main/java/core/kobaco/infra/config/SwaggerConfig.java b/kobaco/kobaco/src/main/java/core/kobaco/infra/config/SwaggerConfig.java new file mode 100644 index 0000000..0e8feac --- /dev/null +++ b/kobaco/kobaco/src/main/java/core/kobaco/infra/config/SwaggerConfig.java @@ -0,0 +1,36 @@ +package core.kobaco.infra.config; + +import core.kobaco.global.jwt.JwtHeaderConsts; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +@Configuration +@SecurityScheme( + type= SecuritySchemeType.APIKEY, + name = JwtHeaderConsts.AUTHORIZATION_HEADER, + in = SecuritySchemeIn.HEADER, description = "Bearer {token}" +) +public class SwaggerConfig { + + @Bean + public GroupedOpenApi api(){ + return GroupedOpenApi.builder() + .group("API") + .addOpenApiCustomizer(openApi -> openApi.info( + new io.swagger.v3.oas.models.info.Info() + .title("Kobaco API") + .version("1.0") + .description("Kobaco API") + ).security( + List.of(new SecurityRequirement().addList(JwtHeaderConsts.AUTHORIZATION_HEADER)) + )).pathsToMatch("/api/**") + .build(); + } +}