diff --git a/src/main/java/com/example/withpeace/config/SwaggerConfig.java b/src/main/java/com/example/withpeace/config/SwaggerConfig.java index 45153d1..1bfd485 100644 --- a/src/main/java/com/example/withpeace/config/SwaggerConfig.java +++ b/src/main/java/com/example/withpeace/config/SwaggerConfig.java @@ -4,6 +4,7 @@ import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.servers.Server; import io.swagger.v3.oas.models.tags.Tag; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import io.swagger.v3.oas.models.Components; @@ -14,8 +15,13 @@ @Configuration public class SwaggerConfig { + + @Value("${swagger.server-url}") + private String serverUrl; + @Bean public OpenAPI openAPI() { + Server server = new Server().url(serverUrl); // 환경별 URL 반영 // 소셜 로그인용 SecurityScheme SecurityScheme socialAuthScheme = new SecurityScheme() @@ -37,15 +43,13 @@ public OpenAPI openAPI() { SecurityRequirement defaultRequirement = new SecurityRequirement() .addList("Access Token"); - Server prodServer = new Server().url("https://cheongha.site"); // 운영 서버 URL - return new OpenAPI() .info(apiInfo()) .components(new Components() .addSecuritySchemes("Social Auth", socialAuthScheme) .addSecuritySchemes("Access Token", accessTokenScheme)) .addSecurityItem(defaultRequirement) // 전역 설정으로 Access Token 사용 - .addServersItem(prodServer) // 운영 서버 URL + .addServersItem(server) .tags(Arrays.asList( new Tag().name("Auth").description("인증 및 회원 관리 API"), diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 4cdbb01..50cfdb5 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -96,6 +96,9 @@ springdoc: swagger-ui: operations-sorter: method # HTTP 메소드 순으로 정렬 (DELETE, GET, PATCH, POST, PUT) +swagger: + server-url: http://localhost:8080 + jwt.secret: ${JWT_SECRET} slack.webhook.url: ${SLACK_WEBHOOK_URL} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 4d17436..605864a 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -98,6 +98,9 @@ springdoc: swagger-ui: operations-sorter: method # HTTP 메소드 순으로 정렬 (DELETE, GET, PATCH, POST, PUT) +swagger: + server-url: https://cheongha.xyz # 운영 서버 URL 설정 + jwt.secret: ${JWT_SECRET} slack.webhook.url: ${SLACK_WEBHOOK_URL} diff --git a/src/main/resources/application-staging.yml b/src/main/resources/application-staging.yml index 46ebdba..66f12bb 100644 --- a/src/main/resources/application-staging.yml +++ b/src/main/resources/application-staging.yml @@ -100,6 +100,9 @@ springdoc: swagger-ui: operations-sorter: method # HTTP 메소드 순으로 정렬 (DELETE, GET, PATCH, POST, PUT) +swagger: + server-url: https://staging.cheongha.xyz # 스테이징 서버 URL 설정 + jwt.secret: ${JWT_SECRET} slack.webhook.url: ${SLACK_WEBHOOK_URL}