Class Picoschema

java.lang.Object
com.google.genkit.prompt.Picoschema

public final class Picoschema extends Object
Converts Picoschema (the compact schema dialect used in .prompt frontmatter) into standard JSON Schema.

Picoschema is a shorthand for describing an object's fields. Given a YAML block already parsed into Java objects, this converter produces a JSON-Schema Map suitable for the Dev UI and generic action runners.

Supported syntax:

  • Scalar fields: fieldName: string (types: string, boolean, null, number, integer, any).
  • Descriptions: fieldName: string, a human description — text after the first comma.
  • Optional fields: fieldName?: string — excluded from required.
  • Wrappers: items(array): string, obj(object): {...}, color(enum): [RED, GREEN]. A comma in the parenthetical adds a description, e.g. tags(array, list of tags): string.
  • Nested objects: a field whose value is a map is treated as a nested object.

This is a pragmatic implementation covering the common cases; if a value already looks like a full JSON Schema (has a JSON-schema type plus properties/items/ $schema) it is passed through unchanged.

  • Method Details

    • convert

      public static Map<String,Object> convert(Object pico)
      Converts a parsed Picoschema definition into a JSON Schema map.
      Parameters:
      pico - the Picoschema value (map, string, or null)
      Returns:
      the JSON schema as a map, or null if pico is null