External JAR & Type Mapping
ใช้ decompile และ custom schema mapper เมื่อ handler/DTO ของโมดูลทั่วไปอยู่นอก source tree.
เพิ่ม jar ตามคลาส
java
var swaggerConfig = SwaggerJsonFileWatcher.Config.builder()
.addDecompileJarClass(com.example.common.web.handler.ApiUploadHandler.class)
.build();ค้นหาตำแหน่ง jar จากแหล่งที่มาของโค้ดของคลาสที่ระบุและ decompile ด้วย CFR เพื่อขยายขอบเขตการวิเคราะห์ route/handler/type ยังมี addDecompileJar ที่ให้เพิ่ม jar path โดยตรง
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 จะจัดการ schema ของประเภทนั้นด้วยการแมพปิ้งแบบกำหนดเอง สามารถใช้กับ wrapper ตัวเลข·วันที่ที่แตกต่างจากรูปแบบการจัดเรียง JSON และ schema OpenAPI ในโปรเจกต์ได้
sourceClasspath
symbol solver ใช้ addSourceClasspath และ sourceClasspath เมื่อไม่สามารถค้นหาแหล่งที่มาภายนอกหรือคลาสที่คอมไพล์ได้ เพียงแค่การนำเข้าไม่สามารถทำให้ parser แปลทุกประเภททั่วไปได้