Class SchemaUtils

java.lang.Object
com.google.genkit.core.SchemaUtils

public final class SchemaUtils extends Object
SchemaUtils provides utilities for JSON Schema generation and validation.
  • Method Details

    • inferSchema

      public static Map<String,Object> inferSchema(Class<?> clazz)
      Generates a JSON Schema for the given class.
      Parameters:
      clazz - the class to generate schema for
      Returns:
      the JSON schema as a map
    • simpleSchema

      public static Map<String,Object> simpleSchema(String typeName)
      Generates a JSON Schema for a primitive type.
      Parameters:
      typeName - the type name (string, number, integer, boolean, array, object)
      Returns:
      the JSON schema as a map
    • stringSchema

      public static Map<String,Object> stringSchema()
      Creates a schema for a string type.
      Returns:
      the string schema
    • integerSchema

      public static Map<String,Object> integerSchema()
      Creates a schema for an integer type.
      Returns:
      the integer schema
    • numberSchema

      public static Map<String,Object> numberSchema()
      Creates a schema for a number type.
      Returns:
      the number schema
    • booleanSchema

      public static Map<String,Object> booleanSchema()
      Creates a schema for a boolean type.
      Returns:
      the boolean schema
    • arraySchema

      public static Map<String,Object> arraySchema(Map<String,Object> itemsSchema)
      Creates a schema for an array type with the given items schema.
      Parameters:
      itemsSchema - the schema for array items
      Returns:
      the array schema
    • objectSchema

      public static Map<String,Object> objectSchema(Map<String,Object> properties)
      Creates a schema for an object type with the given properties.
      Parameters:
      properties - the property schemas
      Returns:
      the object schema