graphqljsonschema

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TopLevelType

func TopLevelType(schema string) (jsonparser.ValueType, error)

Types

type Any

type Any struct{}

func NewAny

func NewAny() Any

func (Any) Kind

func (a Any) Kind() Kind

type Array

type Array struct {
	Type     []string              `json:"type"`
	Items    JsonSchema            `json:"items"`
	MinItems *int                  `json:"minItems,omitempty"`
	Defs     map[string]JsonSchema `json:"$defs,omitempty"`
}

func NewArray

func NewArray(itemSchema JsonSchema, nonNull bool) Array

func (Array) Kind

func (Array) Kind() Kind

type Boolean

type Boolean struct {
	Type []string `json:"type"`
}

func NewBoolean

func NewBoolean(nonNull bool) Boolean

func (Boolean) Kind

func (Boolean) Kind() Kind

type ID

type ID struct {
	Type []string `json:"type"`
}

func NewID

func NewID(nonNull bool) ID

func (ID) Kind

func (ID) Kind() Kind

type Integer

type Integer struct {
	Type []string `json:"type"`
}

func NewInteger

func NewInteger(nonNull bool) Integer

func (Integer) Kind

func (Integer) Kind() Kind

type JsonSchema

type JsonSchema interface {
	Kind() Kind
}

func FromTypeRef

func FromTypeRef(operation, definition *ast.Document, typeRef int, opts ...Option) JsonSchema

type Kind

type Kind int
const (
	StringKind Kind = iota + 1
	NumberKind
	BooleanKind
	IntegerKind
	ObjectKind
	ArrayKind
	AnyKind
	IDKind
	RefKind
)

type Number

type Number struct {
	Type []string `json:"type"`
}

func NewNumber

func NewNumber(nonNull bool) Number

func (Number) Kind

func (Number) Kind() Kind

type Object

type Object struct {
	Type                 []string              `json:"type"`
	Properties           map[string]JsonSchema `json:"properties,omitempty"`
	Required             []string              `json:"required,omitempty"`
	AdditionalProperties bool                  `json:"additionalProperties"`
	Defs                 map[string]JsonSchema `json:"$defs,omitempty"`
}

func NewObject

func NewObject(nonNull bool) Object

func NewObjectAny

func NewObjectAny(nonNull bool) Object

func (Object) Kind

func (Object) Kind() Kind

type Option

type Option func(opts *options)

func WithOverrides

func WithOverrides(overrides map[string]JsonSchema) Option

func WithPath

func WithPath(path []string) Option

type Ref

type Ref struct {
	Ref string `json:"$ref"`
}

func NewRef

func NewRef(definitionName string) Ref

func (Ref) Kind

func (Ref) Kind() Kind

type String

type String struct {
	Type []string `json:"type"`
}

func NewString

func NewString(nonNull bool) String

func (String) Kind

func (String) Kind() Kind

type Validator

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

func MustNewValidatorFromSchema

func MustNewValidatorFromSchema(schema JsonSchema) *Validator

func MustNewValidatorFromString

func MustNewValidatorFromString(schema string) *Validator

func NewValidatorFromSchema

func NewValidatorFromSchema(schema JsonSchema) (*Validator, error)

func NewValidatorFromString

func NewValidatorFromString(schema string) (*Validator, error)

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, inputJSON []byte) error

Jump to

Keyboard shortcuts

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