Class JsonSchemaUtils

java.lang.Object
org.springframework.ai.util.json.schema.JsonSchemaUtils

public final class JsonSchemaUtils extends Object
Utility methods for working with JSON schemas.
Since:
1.0.0
Author:
Guangdong Liu, Ilayaperumal Gopinathan
  • Method Details

    • ensureValidInputSchema

      public static String ensureValidInputSchema(String inputSchema)
      Ensures that the input schema is valid for AI model APIs. Many AI models require that the parameters object must have a "properties" field, even if it's empty. This method normalizes schemas from external sources (like MCP tools) that may not include this field.
      Parameters:
      inputSchema - the input schema as a JSON string
      Returns:
      a valid input schema as a JSON string with required fields