diff --git a/spring-ai-model/src/main/java/org/springframework/ai/converter/BeanOutputConverter.java b/spring-ai-model/src/main/java/org/springframework/ai/converter/BeanOutputConverter.java index 4430ef54992..d40e15ef508 100644 --- a/spring-ai-model/src/main/java/org/springframework/ai/converter/BeanOutputConverter.java +++ b/spring-ai-model/src/main/java/org/springframework/ai/converter/BeanOutputConverter.java @@ -203,6 +203,7 @@ private void generateSchema() { SchemaGeneratorConfig config = configBuilder.build(); SchemaGenerator generator = new SchemaGenerator(config); JsonNode jsonNode = generator.generateSchema(this.type); + postProcessSchema(jsonNode); ObjectWriter objectWriter = this.objectMapper.writer(new DefaultPrettyPrinter() .withObjectIndenter(new DefaultIndenter().withLinefeed(System.lineSeparator()))); try { @@ -214,6 +215,13 @@ private void generateSchema() { } } + /** + * Empty template method that allows for customization of the JSON schema in subclasses. + * @param jsonNode the JSON schema, in the form of a JSON node + */ + protected void postProcessSchema(@NonNull JsonNode jsonNode) { + } + /** * Parses the given text to transform it to the desired target type. * @param text The LLM output in string format.