graphqljsonschema

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 7 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