diff --git a/noti-service/src/main/java/com/waither/notiservice/config/SwaggerConfig.java b/noti-service/src/main/java/com/waither/notiservice/config/SwaggerConfig.java index 4fc2f6c8..170601e1 100644 --- a/noti-service/src/main/java/com/waither/notiservice/config/SwaggerConfig.java +++ b/noti-service/src/main/java/com/waither/notiservice/config/SwaggerConfig.java @@ -3,6 +3,8 @@ 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.servers.Server; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -11,13 +13,28 @@ public class SwaggerConfig { @Bean - public OpenAPI springShopOpenAPI() { + public OpenAPI waitherAPI() { + Info info = new Info() + .title("Waither Notification API Docs") + .description("Waither Notification Service API 명세서입니다.") + .version("1.0.0"); + + String jwtSchemeName = "accessToken"; + // API 요청헤더에 인증정보 포함 + SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName); + + // SecuritySchemes 등록 + Components components = new Components() + .addSecuritySchemes(jwtSchemeName, new SecurityScheme() + .name(jwtSchemeName) + .type(SecurityScheme.Type.HTTP) // HTTP 방식 + .scheme("bearer") + .bearerFormat("JWT")); + return new OpenAPI() - .components(new Components()) .addServersItem(new Server().url("/")) - .info(new Info().title("noti-service API") - .description("Waither noti-service API 명세서입니다.") - .version("v0.0.1") - ); + .info(info) + .addSecurityItem(securityRequirement) + .components(components); } } diff --git a/user-service/src/main/java/com/waither/userservice/config/SwaggerConfig.java b/user-service/src/main/java/com/waither/userservice/config/SwaggerConfig.java new file mode 100644 index 00000000..a60f0b21 --- /dev/null +++ b/user-service/src/main/java/com/waither/userservice/config/SwaggerConfig.java @@ -0,0 +1,40 @@ +package com.waither.userservice.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.servers.Server; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfig { + + @Bean + public OpenAPI waitherAPI() { + Info info = new Info() + .title("Waither User API Docs") + .description("Waither User Service API 명세서입니다.") + .version("1.0.0"); + + String jwtSchemeName = "accessToken"; + // API 요청헤더에 인증정보 포함 + SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName); + + // SecuritySchemes 등록 + Components components = new Components() + .addSecuritySchemes(jwtSchemeName, new SecurityScheme() + .name(jwtSchemeName) + .type(SecurityScheme.Type.HTTP) // HTTP 방식 + .scheme("bearer") + .bearerFormat("JWT")); + + return new OpenAPI() + .addServersItem(new Server().url("/")) + .info(info) + .addSecurityItem(securityRequirement) + .components(components); + } +} diff --git a/weather-service/src/main/java/com/waither/weatherservice/swagger/SwaggerConfig.java b/weather-service/src/main/java/com/waither/weatherservice/swagger/SwaggerConfig.java new file mode 100644 index 00000000..71c3e872 --- /dev/null +++ b/weather-service/src/main/java/com/waither/weatherservice/swagger/SwaggerConfig.java @@ -0,0 +1,27 @@ +package com.waither.weatherservice.swagger; + +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.servers.Server; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfig { + + @Bean + public OpenAPI waitherAPI() { + Info info = new Info() + .title("Waither Weather API Docs") + .description("Waither Weather Service API 명세서입니다.") + .version("1.0.0"); + + + return new OpenAPI() + .addServersItem(new Server().url("/")) + .info(info); + } +}