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

schema

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRequired

func IsRequired(tool Tool, property string) bool

func SnapshotDigest

func SnapshotDigest(data []byte) string

func SortedProperties

func SortedProperties(tool Tool) []string

func ValidateCoverage

func ValidateCoverage(snapshot Snapshot, snapshotData []byte, manifest Manifest) error

Types

type Annotations

type Annotations struct {
	DestructiveHint bool `json:"destructiveHint"`
	IdempotentHint  bool `json:"idempotentHint"`
	OpenWorldHint   bool `json:"openWorldHint"`
	ReadOnlyHint    bool `json:"readOnlyHint"`
}

type JSONSchema

type JSONSchema struct {
	Schema               string              `json:"$schema,omitempty"`
	Type                 string              `json:"type,omitempty"`
	Description          string              `json:"description,omitempty"`
	Properties           map[string]Property `json:"properties,omitempty"`
	Required             []string            `json:"required,omitempty"`
	AdditionalProperties any                 `json:"additionalProperties,omitempty"`
	// contains filtered or unexported fields
}

func (JSONSchema) CompileInputSchema

func (s JSONSchema) CompileInputSchema() error

CompileInputSchema verifies that the complete, original schema can be loaded and resolved by the standards-compliant Draft 7 / Draft 2020-12 validator.

func (JSONSchema) MarshalJSON

func (s JSONSchema) MarshalJSON() ([]byte, error)

func (*JSONSchema) UnmarshalJSON

func (s *JSONSchema) UnmarshalJSON(data []byte) error

func (JSONSchema) ValidateInput

func (s JSONSchema) ValidateInput(instance any) error

ValidateInput validates a JSON value against the complete original schema. Business and authorization rules remain exclusively server-authoritative.

type Manifest

type Manifest struct {
	ManifestVersion int               `json:"manifest_version"`
	SnapshotVersion int               `json:"snapshot_version"`
	SnapshotDigest  string            `json:"snapshot_sha256"`
	Endpoint        string            `json:"endpoint"`
	Tools           []ToolMapping     `json:"tools"`
	Resources       []ResourceMapping `json:"resources"`
}

func BuildManifest

func BuildManifest(snapshot Snapshot, snapshotData []byte) Manifest

func ParseManifest

func ParseManifest(data []byte) (Manifest, error)

type Property

type Property struct {
	Type        any             `json:"type,omitempty"`
	Description string          `json:"description,omitempty"`
	Format      string          `json:"format,omitempty"`
	Enum        []any           `json:"enum,omitempty"`
	Items       json.RawMessage `json:"items,omitempty"`
	Default     any             `json:"default,omitempty"`
	OneOf       []any           `json:"oneOf,omitempty"`
	AnyOf       []any           `json:"anyOf,omitempty"`
	// contains filtered or unexported fields
}

func (Property) ItemProperty

func (p Property) ItemProperty() (Property, bool)

ItemProperty returns the item schema used by a homogeneous array property. Boolean and tuple item schemas deliberately return false: they remain fully supported by JSON validation, but do not have an unambiguous scalar CLI flag.

func (Property) MarshalJSON

func (p Property) MarshalJSON() ([]byte, error)

func (Property) PrimaryType

func (p Property) PrimaryType() string

func (*Property) UnmarshalJSON

func (p *Property) UnmarshalJSON(data []byte) error

type Resource

type Resource struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type ResourceMapping

type ResourceMapping struct {
	Resource    string `json:"resource"`
	URITemplate string `json:"uri_template"`
	Command     string `json:"command"`
}

type Snapshot

type Snapshot struct {
	SnapshotVersion int        `json:"snapshot_version"`
	GeneratedAt     string     `json:"generated_at"`
	Source          string     `json:"source"`
	Endpoint        string     `json:"endpoint"`
	Tools           []Tool     `json:"tools"`
	Resources       []Resource `json:"resources"`
}

func ParseSnapshot

func ParseSnapshot(data []byte) (Snapshot, error)

type Tool

type Tool struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	InputSchema JSONSchema  `json:"inputSchema"`
	Annotations Annotations `json:"annotations"`
}

func ToolByName

func ToolByName(snapshot Snapshot, name string) (Tool, bool)

type ToolMapping

type ToolMapping struct {
	Tool     string `json:"tool"`
	Domain   string `json:"domain"`
	Command  string `json:"command"`
	ReadOnly bool   `json:"read_only"`
}

func (ToolMapping) Path

func (m ToolMapping) Path() string

type ValidationError

type ValidationError struct {
	Path       string   `json:"path"`
	Constraint string   `json:"constraint"`
	Expected   string   `json:"expected,omitempty"`
	Properties []string `json:"properties,omitempty"`
}

ValidationError is a value-free, user-facing description of a JSON Schema failure. It intentionally never includes the rejected instance value.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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