Skip to content

Commit

Permalink
✨feat : Swagger Config 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
DDonghyeo committed May 27, 2024
1 parent c09d7c7 commit f38b85f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit f38b85f

Please sign in to comment.