Class Schema

java.lang.Object
io.github.glaforge.gemini.schema.Schema
Direct Known Subclasses:
ArraySchema, BooleanSchema, NumberSchema, ObjectSchema, StringSchema

public abstract class Schema extends Object
Abstract base class for all Gemini JSON Schemas.
  • Field Details

    • type

      protected String type
      The JSON schema type.
    • description

      protected String description
      The description of the parameter.
    • title

      protected String title
      The title of the parameter.
    • nullable

      protected boolean nullable
      Whether the parameter is nullable.
  • Constructor Details

    • Schema

      protected Schema(String type)
      Initializes a new schema with the given type.
      Parameters:
      type - The JSON schema type.
  • Method Details

    • desc

      public Schema desc(String description)
      Set the description for this schema.
      Parameters:
      description - The description string.
      Returns:
      The schema instance.
    • title

      public Schema title(String title)
      Set the title for this schema.
      Parameters:
      title - The title string.
      Returns:
      The schema instance.
    • nullable

      public Schema nullable()
      Mark this schema as nullable. This will change the type in the JSON output to an array ["originalType", "null"].
      Returns:
      The schema instance.
    • toMap

      public Map<String,Object> toMap()
      Convert this Schema object into a Map suitable for JSON serialization.
      Returns:
      A Map representing the JSON schema.