Documentation
¶
Overview ¶
Package schema generates JSON Schema from Go types, compiles and validates instances, and produces RFC 8785 canonical JSON for content-addressing.
Generation maps []byte and named types over []byte to nullable strings with contentEncoding "base64". json.RawMessage accepts any JSON value including null. Fixed-length [N]byte arrays remain JSON arrays of integers.
Struct schemas follow encoding/json object keys for promoted fields, nested tagged embeds and exported anonymous non-struct fields; a struct that embeds json.RawMessage (value or pointer) admits any JSON value at that schema node; unsupported embeds such as channels fail at generation.
Untrusted JSON is bounded: nesting depth at most 10000; number literals at most 1000 mantissa digits and exponent magnitude at most 8192; canonicalization still enforces exact IEEE-754 doubles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Canonicalize ¶
Canonicalize returns the RFC 8785 canonical form of text.
func ErrLocation ¶
ErrLocation returns the instance JSON Pointer from a platform error, if any.
func ReferenceFromErr ¶
ReferenceFromErr returns an external reference named in a compilation error.
Types ¶
type Compiled ¶
type Compiled struct {
// contains filtered or unexported fields
}
Compiled is a schema ready to validate instances against.
type Schema ¶
type Schema struct {
Raw json.RawMessage
}
Schema is a JSON Schema document, usually generated from a Go type.
type SchemaViolation ¶
type SchemaViolation struct {
SchemaLocation string `json:"schema_location"`
Keyword string `json:"keyword"`
Message string `json:"message"`
}
SchemaViolation is a metaschema failure while compiling a schema.
func SchemaViolations ¶
func SchemaViolations(err error) []SchemaViolation
SchemaViolations returns compilation violations from err.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is the closed world of schemas a document may refer to.