Class JsonSchemaGenerator
java.lang.Object
org.springframework.ai.util.json.schema.JsonSchemaGenerator
Utilities to generate JSON Schemas from Java types and method signatures. It's designed
to work well in the context of tool calling and structured outputs, aiming at ensuring
consistency and robustness across different model providers.
Metadata such as descriptions and required properties can be specified using one of the following supported annotations:
@ToolParam(required = ..., description = ...)@JsonProperty(required = ...)@JsonClassDescription(...)@JsonPropertyDescription(...)@Schema(required = ..., description = ...)@Nullable
If none of these annotations are present, the default behavior is to consider the property as required and not to include a description.
- Since:
- 1.0.0
- Author:
- Thomas Vitale
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOptions for generating JSON Schemas. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconvertTypeValuesToUpperCase(com.fasterxml.jackson.databind.node.ObjectNode node) static StringgenerateForMethodInput(Method method, JsonSchemaGenerator.SchemaOption... schemaOptions) Generate a JSON Schema for a method's input parameters.static StringgenerateForType(Type type, JsonSchemaGenerator.SchemaOption... schemaOptions) Generate a JSON Schema for a class type.
-
Method Details
-
generateForMethodInput
public static String generateForMethodInput(Method method, JsonSchemaGenerator.SchemaOption... schemaOptions) Generate a JSON Schema for a method's input parameters. -
generateForType
Generate a JSON Schema for a class type. -
convertTypeValuesToUpperCase
public static void convertTypeValuesToUpperCase(com.fasterxml.jackson.databind.node.ObjectNode node)
-