Skip to main content
Schemas define reusable object shapes.
Use schemas anywhere a type is expected.

Nested reusable fields

A schema field can be referenced from another schema.

Supported schema field types

Schemas support the full type system. Common options:
  • Primitive: string, number, float, boolean, null
  • Any object: object
  • Arrays: [string], fixed length [string; 3]
  • Tuples: (string, number)
  • Objects: { title: string, score: number }
  • Enums: enum { draft, ready, published }
  • Unions: string | number
  • Nullable values: maybe string
  • Schema references: schema.shared.status
  • Variants (tagged unions): variant kind { ... }
Example with multiple types:

Variants

Use variant when a value can be one of multiple structured cases, each identified by a discriminator field.
In this example, type is the discriminator and each case defines its own object shape.

Field descriptions

Use triple-slash comments to document schema fields. These descriptions are preserved for schema-aware tooling and can improve structured output quality.

Enum formatting

Inline enum variants use commas:
Multiline enum variants do not require commas: