Merge pull request 'feat(swagger): 배포 환경에 따른 Swagger 페이지 노출 제한 (#135)' (#137) from feature/ISSUE-135-swagger-env-restriction into develop
This commit is contained in:
커밋
b912d015b2
@ -11,6 +11,10 @@
|
|||||||
- Screening Guide 탭 분리 (Ship Compliance / Company Compliance)
|
- Screening Guide 탭 분리 (Ship Compliance / Company Compliance)
|
||||||
- Change History ↔ Screening Guide 간 언어 설정 공유 (localStorage)
|
- Change History ↔ Screening Guide 간 언어 설정 공유 (localStorage)
|
||||||
- 섹션 헤더에 Screening Guide 연결 링크 추가
|
- 섹션 헤더에 Screening Guide 연결 링크 추가
|
||||||
|
- 배포 환경에 따른 Swagger 페이지 노출 제한 (#135)
|
||||||
|
- prod 환경에서 Bypass API 그룹만 노출
|
||||||
|
- 그룹별 개별 API 설명 추가
|
||||||
|
- prod 환경 서버 목록 GC 도메인만 표시
|
||||||
|
|
||||||
## [2026-04-01]
|
## [2026-04-01]
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import io.swagger.v3.oas.models.info.License;
|
|||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
import org.springdoc.core.models.GroupedOpenApi;
|
import org.springdoc.core.models.GroupedOpenApi;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@ -20,10 +21,9 @@ import java.util.List;
|
|||||||
* - API 문서 (JSON): http://localhost:8041/snp-api/v3/api-docs
|
* - API 문서 (JSON): http://localhost:8041/snp-api/v3/api-docs
|
||||||
* - API 문서 (YAML): http://localhost:8041/snp-api/v3/api-docs.yaml
|
* - API 문서 (YAML): http://localhost:8041/snp-api/v3/api-docs.yaml
|
||||||
*
|
*
|
||||||
* 주요 기능:
|
* 환경별 노출:
|
||||||
* - REST API 자동 문서화
|
* - dev: 모든 API 그룹 노출
|
||||||
* - API 테스트 UI 제공
|
* - prod: Bypass API 그룹만 노출
|
||||||
* - OpenAPI 3.0 스펙 준수
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
@ -34,27 +34,45 @@ public class SwaggerConfig {
|
|||||||
@Value("${server.servlet.context-path:}")
|
@Value("${server.servlet.context-path:}")
|
||||||
private String contextPath;
|
private String contextPath;
|
||||||
|
|
||||||
|
@Value("${app.environment:dev}")
|
||||||
|
private String environment;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnProperty(name = "app.environment", havingValue = "dev", matchIfMissing = true)
|
||||||
public GroupedOpenApi batchManagementApi() {
|
public GroupedOpenApi batchManagementApi() {
|
||||||
return GroupedOpenApi.builder()
|
return GroupedOpenApi.builder()
|
||||||
.group("1. Batch Management")
|
.group("1. Batch Management")
|
||||||
.pathsToMatch("/api/batch/**")
|
.pathsToMatch("/api/batch/**")
|
||||||
|
.addOpenApiCustomizer(openApi -> openApi.info(new Info()
|
||||||
|
.title("Batch Management API")
|
||||||
|
.description("배치 Job 실행, 이력 조회, 스케줄 관리 API")
|
||||||
|
.version("v1.0.0")))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnProperty(name = "app.environment", havingValue = "dev", matchIfMissing = true)
|
||||||
public GroupedOpenApi bypassConfigApi() {
|
public GroupedOpenApi bypassConfigApi() {
|
||||||
return GroupedOpenApi.builder()
|
return GroupedOpenApi.builder()
|
||||||
.group("2. Bypass Config")
|
.group("2. Bypass Config")
|
||||||
.pathsToMatch("/api/bypass-config/**")
|
.pathsToMatch("/api/bypass-config/**")
|
||||||
|
.addOpenApiCustomizer(openApi -> openApi.info(new Info()
|
||||||
|
.title("Bypass Config API")
|
||||||
|
.description("Bypass API 설정 및 코드 생성 관리 API")
|
||||||
|
.version("v1.0.0")))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnProperty(name = "app.environment", havingValue = "dev", matchIfMissing = true)
|
||||||
public GroupedOpenApi screeningGuideApi() {
|
public GroupedOpenApi screeningGuideApi() {
|
||||||
return GroupedOpenApi.builder()
|
return GroupedOpenApi.builder()
|
||||||
.group("4. Screening Guide")
|
.group("4. Screening Guide")
|
||||||
.pathsToMatch("/api/screening-guide/**")
|
.pathsToMatch("/api/screening-guide/**")
|
||||||
|
.addOpenApiCustomizer(openApi -> openApi.info(new Info()
|
||||||
|
.title("Screening Guide API")
|
||||||
|
.description("Risk & Compliance Screening Guide 조회 API")
|
||||||
|
.version("v1.0.0")))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,14 +82,21 @@ public class SwaggerConfig {
|
|||||||
.group("3. Bypass API")
|
.group("3. Bypass API")
|
||||||
.pathsToMatch("/api/**")
|
.pathsToMatch("/api/**")
|
||||||
.pathsToExclude("/api/batch/**", "/api/bypass-config/**", "/api/screening-guide/**")
|
.pathsToExclude("/api/batch/**", "/api/bypass-config/**", "/api/screening-guide/**")
|
||||||
|
.addOpenApiCustomizer(openApi -> openApi.info(new Info()
|
||||||
|
.title("Bypass API")
|
||||||
|
.description("외부 연동용 S&P 데이터 Bypass API")
|
||||||
|
.version("v1.0.0")))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OpenAPI openAPI() {
|
public OpenAPI openAPI() {
|
||||||
return new OpenAPI()
|
List<Server> servers = "prod".equals(environment)
|
||||||
.info(apiInfo())
|
? List.of(
|
||||||
.servers(List.of(
|
new Server()
|
||||||
|
.url("https://guide.gc-si.dev" + contextPath)
|
||||||
|
.description("GC 도메인"))
|
||||||
|
: List.of(
|
||||||
new Server()
|
new Server()
|
||||||
.url("http://localhost:" + serverPort + contextPath)
|
.url("http://localhost:" + serverPort + contextPath)
|
||||||
.description("로컬 개발 서버"),
|
.description("로컬 개발 서버"),
|
||||||
@ -80,11 +105,14 @@ public class SwaggerConfig {
|
|||||||
.description("중계 서버"),
|
.description("중계 서버"),
|
||||||
new Server()
|
new Server()
|
||||||
.url("https://guide.gc-si.dev" + contextPath)
|
.url("https://guide.gc-si.dev" + contextPath)
|
||||||
.description("GC 도메인")
|
.description("GC 도메인"));
|
||||||
));
|
|
||||||
|
return new OpenAPI()
|
||||||
|
.info(defaultApiInfo())
|
||||||
|
.servers(servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Info apiInfo() {
|
private Info defaultApiInfo() {
|
||||||
return new Info()
|
return new Info()
|
||||||
.title("SNP Batch REST API")
|
.title("SNP Batch REST API")
|
||||||
.description("""
|
.description("""
|
||||||
|
|||||||
@ -77,6 +77,7 @@ logging:
|
|||||||
|
|
||||||
# Custom Application Properties
|
# Custom Application Properties
|
||||||
app:
|
app:
|
||||||
|
environment: prod
|
||||||
batch:
|
batch:
|
||||||
chunk-size: 1000
|
chunk-size: 1000
|
||||||
schedule:
|
schedule:
|
||||||
|
|||||||
불러오는 중...
Reference in New Issue
Block a user