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 = ...)
@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
Modifier and TypeClassDescriptionstatic enum
Options for generating JSON Schemas. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
generateForMethodInput
(Method method, JsonSchemaGenerator.SchemaOption... schemaOptions) Generate a JSON Schema for a method's input parameters.static String
generateForType
(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.
-