schema

package
v0.1.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package schema provides helpers for working with JSON Schema definitions in the AI SDK ecosystem.

This is the Go equivalent of the AI SDK's jsonSchema function.

The package provides type-safe JSON Schema construction utilities that integrate with the tool and structured-output systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONSchema

type JSONSchema struct {
	// contains filtered or unexported fields
}

JSONSchema is a builder for constructing JSON Schema objects that are compatible with AI model tool definitions and structured outputs.

func Array

func Array() *JSONSchema

Array creates a JSONSchema builder for an array type.

func NewJSONSchema

func NewJSONSchema(schemaType string) *JSONSchema

NewJSONSchema creates a new JSONSchema builder initialised with the given type.

func Object

func Object() *JSONSchema

Object creates a JSONSchema builder for an object type.

func (*JSONSchema) BoolProp

func (s *JSONSchema) BoolProp(name, description string) *JSONSchema

BoolProp adds a boolean property to an object schema.

func (*JSONSchema) Build

func (s *JSONSchema) Build() json.RawMessage

Build returns the schema as a json.RawMessage suitable for use in tool definitions and structured output specifications.

func (*JSONSchema) Description

func (s *JSONSchema) Description(desc string) *JSONSchema

Description sets the schema description.

func (*JSONSchema) Items

func (s *JSONSchema) Items(item *JSONSchema) *JSONSchema

Items sets the items schema for an array type.

func (*JSONSchema) NumberProp

func (s *JSONSchema) NumberProp(name, description string) *JSONSchema

NumberProp adds a number property to an object schema.

func (*JSONSchema) Required

func (s *JSONSchema) Required(names ...string) *JSONSchema

Required marks the named properties as required.

func (*JSONSchema) StringProp

func (s *JSONSchema) StringProp(name, description string) *JSONSchema

StringProp adds a string property to an object schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL