From 4b85d97913c5e82241dd6ed3700a6b7365806b85 Mon Sep 17 00:00:00 2001 From: chanwoo7 Date: Fri, 16 Aug 2024 23:30:25 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[chore]=20=EC=A4=91=EB=B3=B5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EB=90=9C=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.gradle b/build.gradle index 9768bfac..c0825080 100644 --- a/build.gradle +++ b/build.gradle @@ -34,9 +34,6 @@ dependencies { // swagger implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' - // swagger - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' - // modelmapper implementation 'org.modelmapper:modelmapper:3.1.0' From 49f53579bb7dba3738a749c30d71840db90e9b57 Mon Sep 17 00:00:00 2001 From: chanwoo7 Date: Fri, 16 Aug 2024 23:38:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[docs]=20Swagger=EC=97=90=EC=84=9C=20JWT=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EC=9E=85=EB=A0=A5=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/backend/global/SwaggerConfig.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/book/backend/global/SwaggerConfig.java b/src/main/java/com/book/backend/global/SwaggerConfig.java index e8dc9985..52714060 100644 --- a/src/main/java/com/book/backend/global/SwaggerConfig.java +++ b/src/main/java/com/book/backend/global/SwaggerConfig.java @@ -1,9 +1,32 @@ package com.book.backend.global; import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import io.swagger.v3.oas.annotations.OpenAPIDefinition; @OpenAPIDefinition(info = @Info(title = "북토크 서버 API", description = "설명", version = "1.0")) // 상단 제목 커스텀 @Configuration -public class SwaggerConfig { } +public class SwaggerConfig { + + @Bean + public OpenAPI api() { + SecurityScheme apiKey = new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .in(SecurityScheme.In.HEADER) + .name("Authorization") + .scheme("bearer") + .bearerFormat("JWT"); + + SecurityRequirement securityRequirement = new SecurityRequirement() + .addList("Bearer Token"); + + return new OpenAPI() + .components(new Components().addSecuritySchemes("Bearer Token", apiKey)) + .addSecurityItem(securityRequirement); + } +}