Class ArraySchema

java.lang.Object
io.github.glaforge.gemini.schema.Schema
io.github.glaforge.gemini.schema.ArraySchema

public class ArraySchema extends Schema
Schema for Array types.

Example usage:


 arr()
     .items(str())
     .minItems(1);
 
  • Constructor Details

    • ArraySchema

      public ArraySchema()
      Initializes a new array schema.
  • Method Details

    • items

      public ArraySchema items(Schema itemsSchema)
      Define the schema for items in this array.
      Parameters:
      itemsSchema - The schema for the items.
      Returns:
      The ArraySchema instance.
    • minItems

      public ArraySchema minItems(int min)
      Set the minimum number of items.
      Parameters:
      min - The minimum number of items.
      Returns:
      The ArraySchema instance.
    • maxItems

      public ArraySchema maxItems(int max)
      Set the maximum number of items.
      Parameters:
      max - The maximum number of items.
      Returns:
      The ArraySchema instance.
    • prefixItems

      public ArraySchema prefixItems(Schema... schemas)
      Define the schema for the first N items (prefixItems).
      Parameters:
      schemas - The schemas for the prefix items.
      Returns:
      The ArraySchema instance.
    • toMap

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