jsonschema

package
v0.0.1-alpha.38 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Schema keywords
	TypeKey                 = "type"
	PropertiesKey           = "properties"
	RequiredKey             = "required"
	ItemsKey                = "items"
	AdditionalPropertiesKey = "additionalProperties"
	RefKey                  = "$ref"
	MinimumKey              = "minimum"
	MaximumKey              = "maximum"
	MultipleOfKey           = "multipleOf"
	MinLengthKey            = "minLength"
	MaxLengthKey            = "maxLength"
	PatternKey              = "pattern"
	FormatKey               = "format"
	MinItemsKey             = "minItems"
	MaxItemsKey             = "maxItems"
	UniqueItemsKey          = "uniqueItems"
	EnumKey                 = "enum"
	TitleKey                = "title"
	DescriptionKey          = "description"
	DefaultKey              = "default"
	OneOfKey                = "oneOf"
	AnyOfKey                = "anyOf"
	AllOfKey                = "allOf"
	NotKey                  = "not"
	DataSourceKey           = "dataSource"
	ComponentIDKey          = "componentId"
	DependencyIDKey         = "dependencyId"
	PositionKey             = "position"
	JSONTag                 = "json"

	// Schema types
	TypeArray   = "array"
	TypeObject  = "object"
	TypeInteger = "integer"
	TypeNumber  = "number"
	TypeBoolean = "boolean"
	TypeString  = "string"
)

JSON Schema constants for keys and types.

Variables

This section is empty.

Functions

func GenerateSchema

func GenerateSchema(t reflect.Type) map[string]any

func GenerateSchemaRawMessage

func GenerateSchemaRawMessage(t reflect.Type) json.RawMessage

GenerateSchemaRawMessage returns a JSON Schema as a raw JSON message.

func GenerateSchemaWithComponents

func GenerateSchemaWithComponents(t reflect.Type) (map[string]any, map[string]any)

func RegisterSchema

func RegisterSchema(t reflect.Type, schema map[string]any)

RegisterSchema registers a custom JSON Schema for a Go type.

func SchemaFrom

func SchemaFrom[T any]() json.RawMessage

SchemaFrom generates a JSON Schema for a generic type T.

Types

type Builder

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

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Components

func (b *Builder) Components() map[string]any

func (*Builder) Schema

func (b *Builder) Schema(t reflect.Type) map[string]any

func (*Builder) SchemaWithComponents

func (b *Builder) SchemaWithComponents(t reflect.Type) (map[string]any, map[string]any)

type OrderedMap

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

func NewOrderedMap

func NewOrderedMap() *OrderedMap

func (*OrderedMap) MarshalJSON

func (m *OrderedMap) MarshalJSON() ([]byte, error)

func (*OrderedMap) MarshalYAML

func (m *OrderedMap) MarshalYAML() (any, error)

func (*OrderedMap) Set

func (m *OrderedMap) Set(key string, value any)

func (*OrderedMap) ToMap

func (m *OrderedMap) ToMap() map[string]any

Jump to

Keyboard shortcuts

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