schema

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayBuilder

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

func Array

func Array() *ArrayBuilder

func Tuple

func Tuple(prefixItems ...Builder) *ArrayBuilder

func (*ArrayBuilder) AnyOf added in v0.2.0

func (b *ArrayBuilder) AnyOf(anyOf ...Builder) *ArrayBuilder

func (*ArrayBuilder) Default

func (b *ArrayBuilder) Default(v []any) *ArrayBuilder

func (*ArrayBuilder) Defs added in v0.2.0

func (b *ArrayBuilder) Defs(defs map[string]Builder) *ArrayBuilder

func (*ArrayBuilder) Deprecated

func (b *ArrayBuilder) Deprecated(deprecated bool) *ArrayBuilder

func (*ArrayBuilder) Description

func (b *ArrayBuilder) Description(description string) *ArrayBuilder

func (*ArrayBuilder) Examples

func (b *ArrayBuilder) Examples(vals ...[]any) *ArrayBuilder

func (*ArrayBuilder) Items

func (b *ArrayBuilder) Items(items Builder) *ArrayBuilder

func (*ArrayBuilder) MaxItems

func (b *ArrayBuilder) MaxItems(n int) *ArrayBuilder

func (*ArrayBuilder) MinItems

func (b *ArrayBuilder) MinItems(n int) *ArrayBuilder

func (*ArrayBuilder) OneOf added in v0.2.0

func (b *ArrayBuilder) OneOf(oneOf ...Builder) *ArrayBuilder

func (*ArrayBuilder) PrefixItems

func (b *ArrayBuilder) PrefixItems(prefixItems ...Builder) *ArrayBuilder

func (*ArrayBuilder) Ref added in v0.2.0

func (b *ArrayBuilder) Ref(ref string) *ArrayBuilder

func (*ArrayBuilder) Schema

func (b *ArrayBuilder) Schema() *Schema

func (*ArrayBuilder) Title

func (b *ArrayBuilder) Title(title string) *ArrayBuilder

func (*ArrayBuilder) UniqueItems

func (b *ArrayBuilder) UniqueItems(v bool) *ArrayBuilder

type BooleanBuilder

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

func Boolean

func Boolean() *BooleanBuilder

func (*BooleanBuilder) AnyOf added in v0.2.0

func (b *BooleanBuilder) AnyOf(anyOf ...Builder) *BooleanBuilder

func (*BooleanBuilder) Const

func (b *BooleanBuilder) Const(v bool) *BooleanBuilder

func (*BooleanBuilder) Default

func (b *BooleanBuilder) Default(v bool) *BooleanBuilder

func (*BooleanBuilder) Deprecated

func (b *BooleanBuilder) Deprecated(deprecated bool) *BooleanBuilder

func (*BooleanBuilder) Description

func (b *BooleanBuilder) Description(description string) *BooleanBuilder

func (*BooleanBuilder) OneOf added in v0.2.0

func (b *BooleanBuilder) OneOf(oneOf ...Builder) *BooleanBuilder

func (*BooleanBuilder) Ref added in v0.2.0

func (b *BooleanBuilder) Ref(ref string) *BooleanBuilder

func (*BooleanBuilder) Schema

func (b *BooleanBuilder) Schema() *Schema

func (*BooleanBuilder) Title

func (b *BooleanBuilder) Title(title string) *BooleanBuilder

type Builder

type Builder interface {
	Schema() *Schema
}

type NullBuilder

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

func Null

func Null() *NullBuilder

func (*NullBuilder) AnyOf added in v0.2.0

func (b *NullBuilder) AnyOf(anyOf ...Builder) *NullBuilder

func (*NullBuilder) Deprecated

func (b *NullBuilder) Deprecated(deprecated bool) *NullBuilder

func (*NullBuilder) Description

func (b *NullBuilder) Description(description string) *NullBuilder

func (*NullBuilder) OneOf added in v0.2.0

func (b *NullBuilder) OneOf(oneOf ...Builder) *NullBuilder

func (*NullBuilder) Ref added in v0.2.0

func (b *NullBuilder) Ref(ref string) *NullBuilder

func (*NullBuilder) Schema

func (b *NullBuilder) Schema() *Schema

func (*NullBuilder) Title

func (b *NullBuilder) Title(title string) *NullBuilder

type NumberBuilder

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

func Number

func Number() *NumberBuilder

func (*NumberBuilder) AnyOf added in v0.2.0

func (b *NumberBuilder) AnyOf(anyOf ...Builder) *NumberBuilder

func (*NumberBuilder) Const

func (b *NumberBuilder) Const(n json.Number) *NumberBuilder

func (*NumberBuilder) Default

func (b *NumberBuilder) Default(n json.Number) *NumberBuilder

func (*NumberBuilder) Deprecated

func (b *NumberBuilder) Deprecated(deprecated bool) *NumberBuilder

func (*NumberBuilder) Description

func (b *NumberBuilder) Description(description string) *NumberBuilder

func (*NumberBuilder) Enum

func (b *NumberBuilder) Enum(vals ...json.Number) *NumberBuilder

func (*NumberBuilder) Examples

func (b *NumberBuilder) Examples(ns ...json.Number) *NumberBuilder

func (*NumberBuilder) ExclusiveMaximum

func (b *NumberBuilder) ExclusiveMaximum(n json.Number) *NumberBuilder

func (*NumberBuilder) ExclusiveMinimum

func (b *NumberBuilder) ExclusiveMinimum(n json.Number) *NumberBuilder

func (*NumberBuilder) Maximum

func (b *NumberBuilder) Maximum(n json.Number) *NumberBuilder

func (*NumberBuilder) Minimum

func (b *NumberBuilder) Minimum(n json.Number) *NumberBuilder

func (*NumberBuilder) MultipleOf

func (b *NumberBuilder) MultipleOf(n json.Number) *NumberBuilder

func (*NumberBuilder) OneOf added in v0.2.0

func (b *NumberBuilder) OneOf(oneOf ...Builder) *NumberBuilder

func (*NumberBuilder) Ref added in v0.2.0

func (b *NumberBuilder) Ref(ref string) *NumberBuilder

func (*NumberBuilder) Schema

func (b *NumberBuilder) Schema() *Schema

func (*NumberBuilder) Title

func (b *NumberBuilder) Title(title string) *NumberBuilder

type ObjectBuilder

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

func Object

func Object() *ObjectBuilder

func Record

func Record(m map[string]Builder) *ObjectBuilder

func (*ObjectBuilder) AdditionalProperties

func (b *ObjectBuilder) AdditionalProperties(s Builder) *ObjectBuilder

func (*ObjectBuilder) AnyOf added in v0.2.0

func (b *ObjectBuilder) AnyOf(anyOf ...Builder) *ObjectBuilder

func (*ObjectBuilder) Default

func (b *ObjectBuilder) Default(v map[string]any) *ObjectBuilder

func (*ObjectBuilder) Defs added in v0.2.0

func (b *ObjectBuilder) Defs(defs map[string]Builder) *ObjectBuilder

func (*ObjectBuilder) DependentRequired

func (b *ObjectBuilder) DependentRequired(names map[string][]string) *ObjectBuilder

func (*ObjectBuilder) Deprecated

func (b *ObjectBuilder) Deprecated(deprecated bool) *ObjectBuilder

func (*ObjectBuilder) Description

func (b *ObjectBuilder) Description(description string) *ObjectBuilder

func (*ObjectBuilder) Examples

func (b *ObjectBuilder) Examples(vals ...map[string]any) *ObjectBuilder

func (*ObjectBuilder) MaxProperties

func (b *ObjectBuilder) MaxProperties(n int) *ObjectBuilder

func (*ObjectBuilder) MinProperties

func (b *ObjectBuilder) MinProperties(n int) *ObjectBuilder

func (*ObjectBuilder) OneOf added in v0.2.0

func (b *ObjectBuilder) OneOf(oneOf ...Builder) *ObjectBuilder

func (*ObjectBuilder) Properties

func (b *ObjectBuilder) Properties(m map[string]Builder) *ObjectBuilder

func (*ObjectBuilder) Ref added in v0.2.0

func (b *ObjectBuilder) Ref(ref string) *ObjectBuilder

func (*ObjectBuilder) Required

func (b *ObjectBuilder) Required(names ...string) *ObjectBuilder

func (*ObjectBuilder) Schema

func (b *ObjectBuilder) Schema() *Schema

func (*ObjectBuilder) Title

func (b *ObjectBuilder) Title(title string) *ObjectBuilder

type Schema

type Schema struct {
	Never  bool `json:"-"`
	Always bool `json:"-"`

	Defs map[string]*Schema `json:"$defs,omitempty"`

	Ref                  string             `json:"$ref,omitempty"`
	AnyOf                []*Schema          `json:"anyOf,omitempty"`
	OneOf                []*Schema          `json:"oneOf,omitempty"`
	PrefixItems          []*Schema          `json:"prefixItems,omitempty"`
	Items                *Schema            `json:"items,omitempty"`
	AdditionalProperties *Schema            `json:"additionalProperties,omitempty"`
	Properties           map[string]*Schema `json:"properties,omitempty"`

	Type              string              `json:"type"`
	Const             any                 `json:"const,omitempty"`
	Enum              []any               `json:"enum,omitempty"`
	MultipleOf        json.Number         `json:"multipleOf,omitempty"`
	Maximum           json.Number         `json:"maximum,omitempty"`
	ExclusiveMaximum  json.Number         `json:"exclusiveMaximum,omitempty"`
	Minimum           json.Number         `json:"minimum,omitempty"`
	ExclusiveMinimum  json.Number         `json:"exclusiveMinimum,omitempty"`
	MaxLength         json.Number         `json:"maxLength,omitempty"`
	MinLength         json.Number         `json:"minLength,omitempty"`
	Pattern           string              `json:"pattern,omitempty"`
	MaxItems          json.Number         `json:"maxItems,omitempty"`
	MinItems          json.Number         `json:"minItems,omitempty"`
	UniqueItems       bool                `json:"uniqueItems,omitempty"`
	MaxProperties     json.Number         `json:"maxProperties,omitempty"`
	MinProperties     json.Number         `json:"minProperties,omitempty"`
	Required          []string            `json:"required,omitempty"`
	DependentRequired map[string][]string `json:"dependentRequired,omitempty"`

	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Default     any    `json:"default,omitempty"`
	Deprecated  bool   `json:"deprecated,omitempty"`
	Examples    []any  `json:"examples,omitempty"`

	// Environments extensions
	Secret bool `json:"secret,omitempty"`
	// contains filtered or unexported fields
}

func Always

func Always() *Schema

func AnyOf added in v0.2.0

func AnyOf(anyOf ...Builder) *Schema

func Never

func Never() *Schema

func OneOf added in v0.2.0

func OneOf(oneOf ...Builder) *Schema

func Ref added in v0.2.0

func Ref(ref string) *Schema

func (*Schema) Compile

func (s *Schema) Compile() error

func (*Schema) GetExclusiveMaximum

func (s *Schema) GetExclusiveMaximum() *big.Float

func (*Schema) GetExclusiveMinimum

func (s *Schema) GetExclusiveMinimum() *big.Float

func (*Schema) GetMaxItems

func (s *Schema) GetMaxItems() *uint

func (*Schema) GetMaxLength

func (s *Schema) GetMaxLength() *uint

func (*Schema) GetMaxProperties

func (s *Schema) GetMaxProperties() *uint

func (*Schema) GetMaximum

func (s *Schema) GetMaximum() *big.Float

func (*Schema) GetMinItems

func (s *Schema) GetMinItems() *uint

func (*Schema) GetMinLength

func (s *Schema) GetMinLength() *uint

func (*Schema) GetMinProperties

func (s *Schema) GetMinProperties() *uint

func (*Schema) GetMinimum

func (s *Schema) GetMinimum() *big.Float

func (*Schema) GetMultipleOf

func (s *Schema) GetMultipleOf() *big.Float

func (*Schema) GetPattern

func (s *Schema) GetPattern() *regexp.Regexp

func (*Schema) GetRef added in v0.2.0

func (s *Schema) GetRef() *Schema

func (*Schema) Item

func (s *Schema) Item(index int) *Schema

func (Schema) MarshalJSON

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

func (*Schema) Property

func (s *Schema) Property(name string) *Schema

func (*Schema) Schema

func (s *Schema) Schema() *Schema

func (*Schema) UnmarshalJSON

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

type StringBuilder

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

func String

func String() *StringBuilder

func (*StringBuilder) AnyOf added in v0.2.0

func (b *StringBuilder) AnyOf(anyOf ...Builder) *StringBuilder

func (*StringBuilder) Const

func (b *StringBuilder) Const(n string) *StringBuilder

func (*StringBuilder) Default

func (b *StringBuilder) Default(n string) *StringBuilder

func (*StringBuilder) Deprecated

func (b *StringBuilder) Deprecated(deprecated bool) *StringBuilder

func (*StringBuilder) Description

func (b *StringBuilder) Description(description string) *StringBuilder

func (*StringBuilder) Enum

func (b *StringBuilder) Enum(vals ...string) *StringBuilder

func (*StringBuilder) Examples

func (b *StringBuilder) Examples(ns ...string) *StringBuilder

func (*StringBuilder) MaxLength

func (b *StringBuilder) MaxLength(n int) *StringBuilder

func (*StringBuilder) MinLength

func (b *StringBuilder) MinLength(n int) *StringBuilder

func (*StringBuilder) OneOf added in v0.2.0

func (b *StringBuilder) OneOf(oneOf ...Builder) *StringBuilder

func (*StringBuilder) Pattern

func (b *StringBuilder) Pattern(pattern string) *StringBuilder

func (*StringBuilder) Ref added in v0.2.0

func (b *StringBuilder) Ref(ref string) *StringBuilder

func (*StringBuilder) Schema

func (b *StringBuilder) Schema() *Schema

func (*StringBuilder) Title

func (b *StringBuilder) Title(title string) *StringBuilder

Jump to

Keyboard shortcuts

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