From e11eeff75e1878ae17763ac0252bb45af0e99b89 Mon Sep 17 00:00:00 2001 From: heesane Date: Thu, 11 Jul 2024 23:39:45 +0900 Subject: [PATCH] swagger fix --- .../home_server/config/SwaggerConfig.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/back/home_server/src/main/java/hhs/server/home_server/config/SwaggerConfig.java b/back/home_server/src/main/java/hhs/server/home_server/config/SwaggerConfig.java index 93a5b98..b1b42a6 100644 --- a/back/home_server/src/main/java/hhs/server/home_server/config/SwaggerConfig.java +++ b/back/home_server/src/main/java/hhs/server/home_server/config/SwaggerConfig.java @@ -1,25 +1,26 @@ package hhs.server.home_server.config; -import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.Components; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class SwaggerConfig { + @Bean - public OpenAPI api() { + public OpenAPI customOpenAPI() { return new OpenAPI() - .components(new Components()) - .info(apiInfo()); + .addSecurityItem(new SecurityRequirement().addList("bearerAuth")) + .components(new Components() + .addSecuritySchemes("bearerAuth", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT"))) + .info(new Info() + .title("Home Server API") + .version("API v1.0") + .description("API documentation")); } - - private Info apiInfo() { - return new Info(). - title("Home Server API"). - version("API v1.0"). - description("API"); - } - } \ No newline at end of file