schema

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package schema models the slice of JSON Schema 2020-12 that the compat-shim emitter cares about. Most of JSON Schema is irrelevant for shim emission — we only need the type, properties, required list, and $defs of every object. Anything else (numeric ranges, format, patternProperties, …) is left to go-jsonschema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schema

type Schema struct {
	// ID corresponds to the JSON Schema `$id` keyword. Used as the match
	// key for cross-tree package mappings (plan §6 schema-packages): when
	// a schema's $id matches an entry in Configuration.SchemaPackages,
	// its types live in another Go package and the compat-shim emitter
	// must skip them (Go forbids methods on imported types).
	ID         string             `json:"$id"`
	Title      string             `json:"title"`
	Type       string             `json:"type"`
	Required   []string           `json:"required"`
	Properties map[string]any     `json:"properties"`
	Defs       map[string]*Schema `json:"$defs"`
	// SourcePath is the absolute path the schema was loaded from. Used
	// only for error messages.
	SourcePath string `json:"-"`
}

Schema is the typed representation of a JSON Schema file. Fields not needed for shim emission are intentionally omitted; unknown properties in the input are dropped during decoding.

func Load

func Load(path string) (*Schema, error)

Load parses a JSON Schema file from disk.

func (*Schema) IsObject

func (s *Schema) IsObject() bool

IsObject reports whether the schema describes a JSON object with named properties.

Jump to

Keyboard shortcuts

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