Help us shape the future of Go! Take the 2026 Go Developer Survey

schema

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package schema holds the published JSON Schema of the Agent Wire Protocol (v0/awp.schema.json) and validates lines against it.

The schema is generated from the wire package by go generate ./wire; it is the same document that https://agentwireprotocol.com/schema/v0/awp.schema.json serves. A test fails when the file is older than the package.

Index

Constants

View Source
const ID = "https://agentwireprotocol.com/schema/v0/awp.schema.json"

ID is the schema's $id.

Variables

View Source
var ErrUnknownType = errors.New("unknown message type")

ErrUnknownType is wrapped by Line for a line whose type the schema does not know. Such a line is still checked against the envelope, since receivers must ignore unknown types (section 5) after reading it.

View Source
var V0 []byte

V0 is the schema document.

Functions

This section is empty.

Types

type Validator

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

Validator checks lines and objects against the schema. It is safe for concurrent use.

func Default

func Default() (*Validator, error)

Default returns a Validator over the embedded schema, compiled once.

func New

func New(doc []byte) (*Validator, error)

New compiles a schema document. Formats (date-time) are asserted.

func (*Validator) Def

func (v *Validator) Def(name string) (*jsonschema.Schema, error)

Def returns the compiled schema of one definition: "Hello", "Part", "Grant", "Presence", ...

func (*Validator) Line

func (v *Validator) Line(line []byte) error

Line validates one line as it travels: a JSON object whose type selects the message definition. A known type is checked against its definition; an unknown type against the envelope only, and the error then wraps ErrUnknownType so callers can treat it as a warning.

func (*Validator) Object

func (v *Validator) Object(def string, doc []byte) error

Object validates a JSON document against a named definition: a grant against "Grant", a presence document against "Presence".

Jump to

Keyboard shortcuts

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