feat(schema): 고급 JSON Schema 제약조건(format, default, examples 등) 지원 및 McpFunction 수정 반영
Some checks failed
Deploy to OCIWP / deploy (push) Has been cancelled

This commit is contained in:
jade
2026-08-03 16:35:46 +09:00
parent be0314afe8
commit 55dcffa2c9
3 changed files with 14 additions and 4 deletions

View File

@@ -27,9 +27,6 @@ public @interface McpFunction {
String prompt() default ""; String prompt() default "";
String mappingId() default ""; String mappingId() default "";
// 추가: 해당 함수가 요구하는 비즈니스 파라미터(JSON 형태의 properties)를 정의
String inputSchema() default "{}";
// 추가: Redis 자동 등록 및 Heartbeat 대상 여부 제어 // 추가: Redis 자동 등록 및 Heartbeat 대상 여부 제어
boolean register() default false; boolean register() default false;

View File

@@ -27,4 +27,7 @@ public @interface McpValidation {
String pattern() default ""; String pattern() default "";
long minimum() default Long.MIN_VALUE; long minimum() default Long.MIN_VALUE;
String[] allowedValues() default {}; String[] allowedValues() default {};
String format() default "";
String defaultValue() default "";
String[] examples() default {};
} }

View File

@@ -42,6 +42,7 @@ public class JsonSchemaGenerator {
private static Map<String, Object> generateSchema(Class<?> clazz, Set<Class<?>> visiting) { private static Map<String, Object> generateSchema(Class<?> clazz, Set<Class<?>> visiting) {
Map<String, Object> schema = new HashMap<>(); Map<String, Object> schema = new HashMap<>();
schema.put("type", "object"); schema.put("type", "object");
schema.put("additionalProperties", false);
if (!visiting.add(clazz)) { if (!visiting.add(clazz)) {
return schema; return schema;
} }
@@ -84,6 +85,15 @@ public class JsonSchemaGenerator {
if (validation != null && validation.allowedValues().length > 0) { if (validation != null && validation.allowedValues().length > 0) {
fieldSchema.put("enum", List.of(validation.allowedValues())); fieldSchema.put("enum", List.of(validation.allowedValues()));
} }
if (validation != null && !validation.format().isEmpty()) {
fieldSchema.put("format", validation.format());
}
if (validation != null && !validation.defaultValue().isEmpty()) {
fieldSchema.put("default", validation.defaultValue());
}
if (validation != null && validation.examples().length > 0) {
fieldSchema.put("examples", List.of(validation.examples()));
}
properties.put(field.getName(), fieldSchema); properties.put(field.getName(), fieldSchema);
} }