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:
부모
91cb3eea19
커밋
b86b063664
@ -10,9 +10,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ public class ComplianceController extends BaseBypassController {
|
||||
summary = "IMO 기반 선박 Compliance 조회 조회",
|
||||
description = "S&P API에서 IMO 기반 선박 Compliance 조회 데이터를 요청하고 응답을 그대로 반환합니다."
|
||||
)
|
||||
@GetMapping
|
||||
@GetMapping("/CompliancesByImos")
|
||||
public ResponseEntity<ApiResponse<List<ComplianceBypassDto>>> getComplianceData(@Parameter(description = "IMO(최대 100개)")
|
||||
@RequestParam(required = true) String 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.GetMapping;\n";
|
||||
|
||||
String mappingPath = buildMappingPath(params);
|
||||
String mappingPath = buildMappingPath(params, config.getExternalPath());
|
||||
String requestMappingPath = "/api/" + domain;
|
||||
|
||||
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()
|
||||
.filter(p -> "PATH".equalsIgnoreCase(p.getParamIn()))
|
||||
.sorted((a, b) -> Integer.compare(a.getSortOrder(), b.getSortOrder()))
|
||||
.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 "";
|
||||
}
|
||||
String path = pathParams.stream()
|
||||
.map(p -> "{" + p.getParamName() + "}")
|
||||
.collect(Collectors.joining("/", "/", ""));
|
||||
return "(\"" + path + "\")";
|
||||
return "(\"" + fullPath + "\")";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user