Documentation
¶
Overview ¶
Package schema provides JSON Schema generation from Go types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Reflector = &jsonschema.Reflector{ DoNotReference: true, }
Reflector is configured for LLM tool/response schemas. DoNotReference inlines all definitions to avoid $ref.
Functions ¶
func Generate ¶
func Generate[T any]() (json.RawMessage, error)
Generate creates a JSON Schema from a Go type. The type should be a struct with json and jsonschema tags.
Example:
type Book struct {
Title string `json:"title" jsonschema:"required,description=The book title"`
Author string `json:"author" jsonschema:"required"`
Year int `json:"year,omitempty"`
}
schema, err := schema.Generate[Book]()
func GenerateFromValue ¶
func GenerateFromValue(v any) (json.RawMessage, error)
GenerateFromValue creates a JSON Schema from a value. This is useful when you have a value instead of a type.
func MustGenerate ¶
func MustGenerate[T any]() json.RawMessage
MustGenerate is like Generate but panics on error. Useful for package-level schema definitions.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.