External JAR & Type Mapping
공통 모듈 handler/DTO가 source tree 밖에 있을 때 decompile과 custom schema mapper를 사용합니다.
Class 기준 jar 추가
java
var swaggerConfig = SwaggerJsonFileWatcher.Config.builder()
.addDecompileJarClass(com.example.common.web.handler.ApiUploadHandler.class)
.build();지정 class의 code source에서 jar 위치를 찾고 CFR로 decompile해 route/handler/type 분석 범위를 넓힙니다. 직접 jar path를 추가하는 addDecompileJar도 제공합니다.
custom type schema
java
var swaggerConfig = SwaggerJsonFileWatcher.Config.builder()
.customTypeMapper((type, schema) -> {
if (type == Long.class || type == BigDecimal.class || type == BigInteger.class) {
schema.put("type", "integer");
schema.put("format", "int64");
return true;
}
return false;
})
.build();predicate가 true를 반환하면 해당 type의 schema를 custom mapping으로 처리합니다. 프로젝트에서 JSON 직렬화 형태와 OpenAPI schema가 달라지는 숫자·날짜 wrapper에 사용할 수 있습니다.
sourceClasspath
symbol solver가 외부 source 또는 compiled class를 찾지 못할 때 addSourceClasspath와 sourceClasspath를 사용합니다. 단순히 import가 존재하는 것만으로 parser가 모든 generic type을 해석할 수 있는 것은 아닙니다.