From 4f8519bb2f2b583da283e93f6707e41bed562d3c Mon Sep 17 00:00:00 2001 From: bjkim Date: Tue, 12 Aug 2025 12:05:50 +0900 Subject: [PATCH] =?UTF-8?q?[ADD]=20SWAGGER=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../etri/autoflow/swagger/OpenAPIConfig.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/kr/re/etri/autoflow/swagger/OpenAPIConfig.java b/src/main/java/kr/re/etri/autoflow/swagger/OpenAPIConfig.java index 3175805..a0bab86 100644 --- a/src/main/java/kr/re/etri/autoflow/swagger/OpenAPIConfig.java +++ b/src/main/java/kr/re/etri/autoflow/swagger/OpenAPIConfig.java @@ -8,13 +8,19 @@ import io.swagger.v3.oas.models.info.License; 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 lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.List; +import org.springframework.core.env.Environment; + @Configuration +@RequiredArgsConstructor public class OpenAPIConfig { + private final Environment environment; + private static final String SECURITY_SCHEME_NAME = "bezkoder-jwt-cookie"; private static final String PRODUCTION_SERVER_URL = "http://cuuva.com:2480/autoflow"; @@ -55,10 +61,27 @@ public class OpenAPIConfig { .url("http://cuuva.com")); } - private List createServerList() { - return List.of( - new Server().url(PRODUCTION_SERVER_URL).description("Production Server"), - new Server().url(LOCAL_SERVER_URL).description("Local Server") - ); + public List createServerList() { + String[] activeProfiles = environment.getActiveProfiles(); + + if (activeProfiles.length == 0) { + // 프로필이 없으면 default + return List.of(new Server().url(LOCAL_SERVER_URL).description("Default Local Server")); + } + + String profile = activeProfiles[0]; + + return switch (profile) { + case "local" -> List.of( + new Server().url(LOCAL_SERVER_URL).description("Local Server") + ); + case "prod" -> List.of( + new Server().url(PRODUCTION_SERVER_URL).description("Production Server") + ); + default -> List.of( + new Server().url(LOCAL_SERVER_URL).description("Default Local Server") + ); + }; } + }