Documentation
¶
Overview ¶
Package jsonschema writes schemas of the spec IR as JSON Schema 2020-12 documents, the way MCP tools describe their input. Every $ref goes through $defs, so a schema that refers to itself ends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder converts schemas into one document and collects what they refer to in its $defs: a component under its name, anything else under its JSON pointer.
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) Diagnostics ¶
func (b *Builder) Diagnostics() []diag.Diagnostic
Diagnostics are the warnings of the schemas converted so far.
func (*Builder) Document ¶
Document returns root with the $defs collected so far, compact. The definitions come sorted by name.
func (*Builder) Schema ¶
Schema converts s. A nil schema is the empty one, which takes anything. A nullable schema takes null: when its $ref, composition, enum or const could turn null away, it is anyOf of itself and null, with its docs and values outside. A readOnly property is left out with its required entry, since a request does not carry it; readOnly in an allOf member counts for the whole object. Each variant of a oneOf with a discriminator requires the property and takes the values that pick it.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is a JSON object whose keys keep the order they were first set in. Values are nil, bool, string, json.Number, []string, []any or *Object; anything else is written as null.
func (*Object) MarshalJSON ¶
MarshalJSON writes the object compact, with HTML characters left as they are.