fix: 내부 API 경로에 externalPath 마지막 세그먼트 반영

/RiskAndCompliance/CompliancesByImos 등록 시
/api/compliance → /api/compliance/CompliancesByImos 로 생성되도록 변경

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
HYOJIN 2026-03-26 17:17:16 +09:00
부모 91cb3eea19
커밋 b86b063664
2개의 변경된 파일25개의 추가작업 그리고 10개의 파일을 삭제

파일 보기

@ -10,9 +10,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
/** /**
@ -31,7 +31,7 @@ public class ComplianceController extends BaseBypassController {
summary = "IMO 기반 선박 Compliance 조회 조회", summary = "IMO 기반 선박 Compliance 조회 조회",
description = "S&P API에서 IMO 기반 선박 Compliance 조회 데이터를 요청하고 응답을 그대로 반환합니다." description = "S&P API에서 IMO 기반 선박 Compliance 조회 데이터를 요청하고 응답을 그대로 반환합니다."
) )
@GetMapping @GetMapping("/CompliancesByImos")
public ResponseEntity<ApiResponse<List<ComplianceBypassDto>>> getComplianceData(@Parameter(description = "IMO(최대 100개)") public ResponseEntity<ApiResponse<List<ComplianceBypassDto>>> getComplianceData(@Parameter(description = "IMO(최대 100개)")
@RequestParam(required = true) String imos) { @RequestParam(required = true) String imos) {
return execute(() -> complianceBypassService.getComplianceData(imos)); return execute(() -> complianceBypassService.getComplianceData(imos));

파일 보기

@ -207,7 +207,7 @@ public class BypassCodeGenerator {
? "import org.springframework.web.bind.annotation.PostMapping;\n" ? "import org.springframework.web.bind.annotation.PostMapping;\n"
: "import org.springframework.web.bind.annotation.GetMapping;\n"; : "import org.springframework.web.bind.annotation.GetMapping;\n";
String mappingPath = buildMappingPath(params); String mappingPath = buildMappingPath(params, config.getExternalPath());
String requestMappingPath = "/api/" + domain; String requestMappingPath = "/api/" + domain;
return """ return """
@ -347,20 +347,35 @@ public class BypassCodeGenerator {
} }
/** /**
* @GetMapping / @PostMapping에 붙는 경로 생성 (PATH 파라미터가 있는 경우) * @GetMapping / @PostMapping에 붙는 경로 생성
* externalPath의 마지막 세그먼트를 내부 경로로 사용 + PATH 파라미터 추가
* : /RiskAndCompliance/CompliancesByImos ("/CompliancesByImos")
* PATH 파라미터 imo 추가 ("/CompliancesByImos/{imo}")
*/ */
private String buildMappingPath(List<BypassApiParam> params) { private String buildMappingPath(List<BypassApiParam> params, String externalPath) {
// externalPath에서 마지막 세그먼트 추출
String endpointSegment = "";
if (externalPath != null && !externalPath.isEmpty()) {
String[] segments = externalPath.split("/");
if (segments.length > 0) {
endpointSegment = "/" + segments[segments.length - 1];
}
}
// PATH 파라미터 추가
List<BypassApiParam> pathParams = params.stream() List<BypassApiParam> pathParams = params.stream()
.filter(p -> "PATH".equalsIgnoreCase(p.getParamIn())) .filter(p -> "PATH".equalsIgnoreCase(p.getParamIn()))
.sorted((a, b) -> Integer.compare(a.getSortOrder(), b.getSortOrder())) .sorted((a, b) -> Integer.compare(a.getSortOrder(), b.getSortOrder()))
.toList(); .toList();
if (pathParams.isEmpty()) { String pathSuffix = pathParams.stream()
.map(p -> "{" + p.getParamName() + "}")
.collect(Collectors.joining("/", pathParams.isEmpty() ? "" : "/", ""));
String fullPath = endpointSegment + pathSuffix;
if (fullPath.isEmpty()) {
return ""; return "";
} }
String path = pathParams.stream() return "(\"" + fullPath + "\")";
.map(p -> "{" + p.getParamName() + "}")
.collect(Collectors.joining("/", "/", ""));
return "(\"" + path + "\")";
} }
/** /**