feat(schema): 고급 JSON Schema 제약조건(format, default, examples 등) 지원 및 McpFunction 수정 반영
Some checks failed
Deploy to OCIWP / deploy (push) Has been cancelled
Some checks failed
Deploy to OCIWP / deploy (push) Has been cancelled
This commit is contained in:
@@ -26,10 +26,7 @@ public @interface McpFunction {
|
||||
String description();
|
||||
String prompt() default "";
|
||||
String mappingId() default "";
|
||||
|
||||
// 추가: 해당 함수가 요구하는 비즈니스 파라미터(JSON 형태의 properties)를 정의
|
||||
String inputSchema() default "{}";
|
||||
|
||||
|
||||
// 추가: Redis 자동 등록 및 Heartbeat 대상 여부 제어
|
||||
boolean register() default false;
|
||||
|
||||
|
||||
@@ -27,4 +27,7 @@ public @interface McpValidation {
|
||||
String pattern() default "";
|
||||
long minimum() default Long.MIN_VALUE;
|
||||
String[] allowedValues() default {};
|
||||
String format() default "";
|
||||
String defaultValue() default "";
|
||||
String[] examples() default {};
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class JsonSchemaGenerator {
|
||||
private static Map<String, Object> generateSchema(Class<?> clazz, Set<Class<?>> visiting) {
|
||||
Map<String, Object> schema = new HashMap<>();
|
||||
schema.put("type", "object");
|
||||
schema.put("additionalProperties", false);
|
||||
if (!visiting.add(clazz)) {
|
||||
return schema;
|
||||
}
|
||||
@@ -84,6 +85,15 @@ public class JsonSchemaGenerator {
|
||||
if (validation != null && validation.allowedValues().length > 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user