fix: include pattern in mcp tool schema generation and scaffold output
All checks were successful
Deploy Tools / deploy (push) Successful in 2m20s

This commit is contained in:
jade
2026-08-19 10:31:46 +09:00
parent 6646741665
commit 317f9865b8
3 changed files with 17 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import jakarta.validation.constraints.Pattern;
/** /**
@@ -71,6 +72,11 @@ public class JsonSchemaGenerator {
requiredList.add(field.getName()); 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); Schema schemaAnnotation = field.getAnnotation(Schema.class);
if (schemaAnnotation != null) { if (schemaAnnotation != null) {
if (!schemaAnnotation.description().isEmpty() && !fieldSchema.containsKey("description")) { if (!schemaAnnotation.description().isEmpty() && !fieldSchema.containsKey("description")) {

View File

@@ -1442,6 +1442,9 @@ public class ToolScaffolder {
properties.append(" ").append(field.name().trim()).append(":\n") properties.append(" ").append(field.name().trim()).append(":\n")
.append(" type: ").append(jsonSchemaType(field.type())).append("\n") .append(" type: ").append(jsonSchemaType(field.type())).append("\n")
.append(" description: ").append(yamlText(richDescription(field))).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()) { if ("Enum".equals(field.type()) && field.enumValues() != null && !field.enumValues().isEmpty()) {
properties.append(" enum: [").append(field.enumValues().stream() properties.append(" enum: [").append(field.enumValues().stream()
.filter(value -> value != null && !value.isBlank()).map(String::trim) .filter(value -> value != null && !value.isBlank()).map(String::trim)
@@ -1456,6 +1459,9 @@ public class ToolScaffolder {
properties.append(" ").append(itemField.name()).append(":\n") properties.append(" ").append(itemField.name()).append(":\n")
.append(" type: ").append(jsonSchemaType(itemField.type())).append("\n") .append(" type: ").append(jsonSchemaType(itemField.type())).append("\n")
.append(" description: ").append(yamlText(richDescription(itemField))).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");
}
} }
} }
} }

View File

@@ -1,5 +1,6 @@
package io.shinhanlife.dap.mcc.biz.pct.dto; package io.shinhanlife.dap.mcc.biz.pct.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.springaicommunity.mcp.annotation.McpToolParam; import org.springaicommunity.mcp.annotation.McpToolParam;
@@ -7,4 +8,8 @@ import org.springaicommunity.mcp.annotation.McpToolParam;
public class SystemNoticeRequest { public class SystemNoticeRequest {
@McpToolParam(description = "공지 분류", required = false) @McpToolParam(description = "공지 분류", required = false)
private String category; private String category;
@McpToolParam(description = "계약심사번호", required = false)
@Schema(pattern = "^[A-Za-z0-9_-]{3,30}$")
private String contractId;
} }