forked from kimhyungsik/ax_hub_mcp_tool
fix: include pattern in mcp tool schema generation and scaffold output
All checks were successful
Deploy Tools / deploy (push) Successful in 2m20s
All checks were successful
Deploy Tools / deploy (push) Successful in 2m20s
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,11 @@ public class JsonSchemaGenerator {
|
||||
requiredList.add(field.getName());
|
||||
}
|
||||
|
||||
Pattern patternAnnotation = field.getAnnotation(Pattern.class);
|
||||
if (patternAnnotation != null && !patternAnnotation.regexp().isEmpty()) {
|
||||
fieldSchema.put("pattern", patternAnnotation.regexp());
|
||||
}
|
||||
|
||||
Schema schemaAnnotation = field.getAnnotation(Schema.class);
|
||||
if (schemaAnnotation != null) {
|
||||
if (!schemaAnnotation.description().isEmpty() && !fieldSchema.containsKey("description")) {
|
||||
|
||||
@@ -1442,6 +1442,9 @@ public class ToolScaffolder {
|
||||
properties.append(" ").append(field.name().trim()).append(":\n")
|
||||
.append(" type: ").append(jsonSchemaType(field.type())).append("\n")
|
||||
.append(" description: ").append(yamlText(richDescription(field))).append("\n");
|
||||
if (field.pattern() != null && !field.pattern().isBlank()) {
|
||||
properties.append(" pattern: ").append(yamlText(field.pattern())).append("\n");
|
||||
}
|
||||
if ("Enum".equals(field.type()) && field.enumValues() != null && !field.enumValues().isEmpty()) {
|
||||
properties.append(" enum: [").append(field.enumValues().stream()
|
||||
.filter(value -> value != null && !value.isBlank()).map(String::trim)
|
||||
@@ -1456,6 +1459,9 @@ public class ToolScaffolder {
|
||||
properties.append(" ").append(itemField.name()).append(":\n")
|
||||
.append(" type: ").append(jsonSchemaType(itemField.type())).append("\n")
|
||||
.append(" description: ").append(yamlText(richDescription(itemField))).append("\n");
|
||||
if (itemField.pattern() != null && !itemField.pattern().isBlank()) {
|
||||
properties.append(" pattern: ").append(yamlText(itemField.pattern())).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user