Documentation ¶
Index ¶
- func IsNullableNode(n Node) bool
- func IsOptionalNode(n Node) bool
- type ArrayNode
- func (n *ArrayNode) ASTNode() (schema.ASTNode, error)
- func (n *ArrayNode) AddConstraint(c constraint.Constraint)
- func (n ArrayNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent
- func (n ArrayNode) Child(i uint) Node
- func (n ArrayNode) Children() []Node
- func (n *ArrayNode) Comment() string
- func (n ArrayNode) Constraint(t constraint.Type) constraint.Constraint
- func (n ArrayNode) ConstraintMap() *Constraints
- func (n *ArrayNode) Copy() Node
- func (n *ArrayNode) DeleteConstraint(t constraint.Type)
- func (n *ArrayNode) Grow(lex lexeme.LexEvent) (Node, bool)
- func (n *ArrayNode) InheritedFrom() string
- func (n ArrayNode) Len() int
- func (n ArrayNode) NumberOfConstraints() int
- func (n ArrayNode) Parent() Node
- func (n *ArrayNode) RealType() string
- func (n ArrayNode) SchemaType() schema.SchemaType
- func (n *ArrayNode) SetComment(s string)
- func (n *ArrayNode) SetInheritedFrom(s string)
- func (n *ArrayNode) SetParent(parent Node)
- func (n *ArrayNode) SetRealType(s string) bool
- func (n ArrayNode) Type() json.Type
- func (n ArrayNode) Value() bytes.Bytes
- type BranchNode
- type Constraints
- func (m *Constraints) Delete(k constraint.Type)
- func (m *Constraints) Each(fn eachConstraintsFunc) error
- func (m *Constraints) EachSafe(fn eachSafeConstraintsFunc)
- func (m *Constraints) Filter(fn filterConstraintsFunc)
- func (m *Constraints) Find(fn findConstraintsFunc) (ConstraintsItem, bool)
- func (m *Constraints) Get(k constraint.Type) (constraint.Constraint, bool)
- func (m *Constraints) GetValue(k constraint.Type) constraint.Constraint
- func (m *Constraints) Has(k constraint.Type) bool
- func (m *Constraints) Len() int
- func (m *Constraints) Map(fn mapConstraintsFunc) error
- func (m *Constraints) MarshalJSON() ([]byte, error)
- func (m *Constraints) Set(k constraint.Type, v constraint.Constraint)
- func (m *Constraints) Update(k constraint.Type, fn func(v constraint.Constraint) constraint.Constraint)
- type ConstraintsItem
- type ISchema
- func (s *ISchema) AddNamedType(name string, typ *ISchema, rootFile *fs.File, begin bytes.Index)
- func (s *ISchema) AddType(n string, t Type)
- func (s *ISchema) AddUnnamedType(typ *ISchema, rootFile *fs.File, begin bytes.Index) string
- func (s ISchema) MustType(name string) *ISchema
- func (s ISchema) RootNode() Node
- func (s *ISchema) SetRootNode(node Node)
- func (s ISchema) Type(name string) (*ISchema, *errs.Err)
- func (s ISchema) TypesList() map[string]Type
- type LiteralNode
- func (n *LiteralNode) ASTNode() (schema.ASTNode, error)
- func (n *LiteralNode) AddConstraint(c constraint.Constraint)
- func (n LiteralNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent
- func (n *LiteralNode) Comment() string
- func (n LiteralNode) Constraint(t constraint.Type) constraint.Constraint
- func (n LiteralNode) ConstraintMap() *Constraints
- func (n *LiteralNode) Copy() Node
- func (n *LiteralNode) DeleteConstraint(t constraint.Type)
- func (n *LiteralNode) Grow(lex lexeme.LexEvent) (Node, bool)
- func (n *LiteralNode) InheritedFrom() string
- func (n LiteralNode) NumberOfConstraints() int
- func (n LiteralNode) Parent() Node
- func (n *LiteralNode) RealType() string
- func (n LiteralNode) SchemaType() schema.SchemaType
- func (n *LiteralNode) SetComment(s string)
- func (n *LiteralNode) SetInheritedFrom(s string)
- func (n *LiteralNode) SetParent(parent Node)
- func (n *LiteralNode) SetRealType(s string) bool
- func (n LiteralNode) Type() json.Type
- func (n LiteralNode) Value() bytes.Bytes
- type MixedNode
- func (n MixedNode) ASTNode() (schema.ASTNode, error)
- func (n *MixedNode) AddConstraint(c constraint.Constraint)
- func (n MixedNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent
- func (n *MixedNode) Comment() string
- func (n MixedNode) Constraint(t constraint.Type) constraint.Constraint
- func (n MixedNode) ConstraintMap() *Constraints
- func (n *MixedNode) Copy() Node
- func (n *MixedNode) DeleteConstraint(t constraint.Type)
- func (*MixedNode) Grow(lexeme.LexEvent) (Node, bool)
- func (n *MixedNode) InheritedFrom() string
- func (n MixedNode) NumberOfConstraints() int
- func (n MixedNode) Parent() Node
- func (n *MixedNode) RealType() string
- func (n MixedNode) SchemaType() schema.SchemaType
- func (n *MixedNode) SetComment(s string)
- func (n *MixedNode) SetInheritedFrom(s string)
- func (n *MixedNode) SetJsonType(t json.Type)
- func (n *MixedNode) SetParent(parent Node)
- func (*MixedNode) SetRealType(string) bool
- func (n MixedNode) Type() json.Type
- func (n MixedNode) Value() bytes.Bytes
- type MixedValueNode
- func (n *MixedValueNode) ASTNode() (schema.ASTNode, error)
- func (n *MixedValueNode) AddConstraint(c constraint.Constraint)
- func (n MixedValueNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent
- func (n *MixedValueNode) Comment() string
- func (n MixedValueNode) Constraint(t constraint.Type) constraint.Constraint
- func (n MixedValueNode) ConstraintMap() *Constraints
- func (n *MixedValueNode) Copy() Node
- func (n *MixedValueNode) DeleteConstraint(t constraint.Type)
- func (n *MixedValueNode) GetTypes() []string
- func (n *MixedValueNode) Grow(lex lexeme.LexEvent) (Node, bool)
- func (n *MixedValueNode) InheritedFrom() string
- func (n MixedValueNode) NumberOfConstraints() int
- func (n MixedValueNode) Parent() Node
- func (n *MixedValueNode) RealType() string
- func (n MixedValueNode) SchemaType() schema.SchemaType
- func (n *MixedValueNode) SetComment(s string)
- func (n *MixedValueNode) SetInheritedFrom(s string)
- func (n *MixedValueNode) SetParent(parent Node)
- func (*MixedValueNode) SetRealType(string) bool
- func (n MixedValueNode) Type() json.Type
- func (n MixedValueNode) Value() bytes.Bytes
- type Node
- type ObjectNode
- func (n *ObjectNode) ASTNode() (schema.ASTNode, error)
- func (n *ObjectNode) AddChild(key ObjectNodeKey, child Node)
- func (n *ObjectNode) AddConstraint(c constraint.Constraint)
- func (n *ObjectNode) AddKey(key string, isShortcut bool, lex lexeme.LexEvent)
- func (n ObjectNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent
- func (n *ObjectNode) Child(key string, isShortcut bool) (Node, bool)
- func (n *ObjectNode) ChildByRawKey(rawKey bytes.Bytes) (Node, bool)
- func (n *ObjectNode) Children() []Node
- func (n *ObjectNode) Comment() string
- func (n ObjectNode) Constraint(t constraint.Type) constraint.Constraint
- func (n ObjectNode) ConstraintMap() *Constraints
- func (n *ObjectNode) Copy() Node
- func (n *ObjectNode) CopyAndLowercaseKeys() *ObjectNode
- func (n *ObjectNode) DeleteConstraint(t constraint.Type)
- func (n *ObjectNode) EnsureAdditionalProperties()
- func (n *ObjectNode) Grow(lex lexeme.LexEvent) (Node, bool)
- func (n *ObjectNode) InheritedFrom() string
- func (n *ObjectNode) Key(index int) ObjectNodeKey
- func (n *ObjectNode) Keys() *ObjectNodeKeys
- func (n *ObjectNode) Len() int
- func (n ObjectNode) NumberOfConstraints() int
- func (n ObjectNode) Parent() Node
- func (n *ObjectNode) RealType() string
- func (n ObjectNode) SchemaType() schema.SchemaType
- func (n *ObjectNode) SetComment(s string)
- func (n *ObjectNode) SetInheritedFrom(s string)
- func (n *ObjectNode) SetParent(parent Node)
- func (n *ObjectNode) SetRealType(s string) bool
- func (*ObjectNode) Type() json.Type
- func (n ObjectNode) Value() bytes.Bytes
- type ObjectNodeKey
- type ObjectNodeKeys
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNullableNode ¶ added in v0.2.0
IsNullableNode returns true is node is nullable.
func IsOptionalNode ¶
IsOptionalNode returns true is node is optional.
Types ¶
type ArrayNode ¶
type ArrayNode struct {
// contains filtered or unexported fields
}
func (*ArrayNode) AddConstraint ¶
func (n *ArrayNode) AddConstraint(c constraint.Constraint)
AddConstraint adds new constraint to this node. Won't add if c is nil.
func (ArrayNode) BasisLexEventOfSchemaForNode ¶
func (ArrayNode) Constraint ¶
func (n ArrayNode) Constraint(t constraint.Type) constraint.Constraint
Constraint returns requested Constraint if found.
func (ArrayNode) ConstraintMap ¶
func (n ArrayNode) ConstraintMap() *Constraints
ConstraintMap returns all constraints.
func (*ArrayNode) DeleteConstraint ¶
func (n *ArrayNode) DeleteConstraint(t constraint.Type)
func (*ArrayNode) InheritedFrom ¶
func (n *ArrayNode) InheritedFrom() string
func (ArrayNode) NumberOfConstraints ¶
func (n ArrayNode) NumberOfConstraints() int
func (ArrayNode) SchemaType ¶
func (n ArrayNode) SchemaType() schema.SchemaType
func (*ArrayNode) SetComment ¶
func (n *ArrayNode) SetComment(s string)
func (*ArrayNode) SetInheritedFrom ¶
func (n *ArrayNode) SetInheritedFrom(s string)
func (*ArrayNode) SetRealType ¶
type BranchNode ¶
BranchNode that can contain child elements (an array or an object).
type Constraints ¶
type Constraints struct {
// contains filtered or unexported fields
}
Constraints an ordered map of node constraints. gen:OrderedMap
func (*Constraints) Delete ¶
func (m *Constraints) Delete(k constraint.Type)
func (*Constraints) Each ¶
func (m *Constraints) Each(fn eachConstraintsFunc) error
func (*Constraints) EachSafe ¶
func (m *Constraints) EachSafe(fn eachSafeConstraintsFunc)
func (*Constraints) Filter ¶
func (m *Constraints) Filter(fn filterConstraintsFunc)
Filter iterates and changes values in the map.
func (*Constraints) Find ¶
func (m *Constraints) Find(fn findConstraintsFunc) (ConstraintsItem, bool)
Find finds first matched item from the map.
func (*Constraints) Get ¶
func (m *Constraints) Get(k constraint.Type) (constraint.Constraint, bool)
Get gets a value by key.
func (*Constraints) GetValue ¶
func (m *Constraints) GetValue(k constraint.Type) constraint.Constraint
GetValue gets a value by key.
func (*Constraints) Has ¶
func (m *Constraints) Has(k constraint.Type) bool
Has checks that specified key is set.
func (*Constraints) Map ¶
func (m *Constraints) Map(fn mapConstraintsFunc) error
Map iterates and changes values in the map.
func (*Constraints) MarshalJSON ¶
func (m *Constraints) MarshalJSON() ([]byte, error)
func (*Constraints) Set ¶
func (m *Constraints) Set(k constraint.Type, v constraint.Constraint)
Set sets a value with specified key.
func (*Constraints) Update ¶
func (m *Constraints) Update(k constraint.Type, fn func(v constraint.Constraint) constraint.Constraint)
Update updates a value with specified key.
type ConstraintsItem ¶
type ConstraintsItem struct { Key constraint.Type Value constraint.Constraint }
ConstraintsItem represent single data from the Constraints.
type ISchema ¶
type ISchema struct {
// contains filtered or unexported fields
}
func (*ISchema) AddNamedType ¶
func (*ISchema) AddUnnamedType ¶
AddUnnamedType Adds an unnamed TYPE to the SCHEMA. Returns a unique name for the added TYPE.
func (*ISchema) SetRootNode ¶
type LiteralNode ¶
type LiteralNode struct {
// contains filtered or unexported fields
}
func (*LiteralNode) AddConstraint ¶
func (n *LiteralNode) AddConstraint(c constraint.Constraint)
AddConstraint adds new constraint to this node. Won't add if c is nil.
func (LiteralNode) BasisLexEventOfSchemaForNode ¶
func (LiteralNode) Constraint ¶
func (n LiteralNode) Constraint(t constraint.Type) constraint.Constraint
Constraint returns requested Constraint if found.
func (LiteralNode) ConstraintMap ¶
func (n LiteralNode) ConstraintMap() *Constraints
ConstraintMap returns all constraints.
func (*LiteralNode) Copy ¶
func (n *LiteralNode) Copy() Node
func (*LiteralNode) DeleteConstraint ¶
func (n *LiteralNode) DeleteConstraint(t constraint.Type)
func (*LiteralNode) InheritedFrom ¶
func (n *LiteralNode) InheritedFrom() string
func (LiteralNode) NumberOfConstraints ¶
func (n LiteralNode) NumberOfConstraints() int
func (LiteralNode) SchemaType ¶
func (n LiteralNode) SchemaType() schema.SchemaType
func (*LiteralNode) SetComment ¶
func (n *LiteralNode) SetComment(s string)
func (*LiteralNode) SetInheritedFrom ¶
func (n *LiteralNode) SetInheritedFrom(s string)
func (*LiteralNode) SetRealType ¶
type MixedNode ¶
type MixedNode struct {
// contains filtered or unexported fields
}
func NewMixedNode ¶
func (*MixedNode) AddConstraint ¶
func (n *MixedNode) AddConstraint(c constraint.Constraint)
AddConstraint adds new constraint to this node. Won't add if c is nil.
func (MixedNode) BasisLexEventOfSchemaForNode ¶
func (MixedNode) Constraint ¶
func (n MixedNode) Constraint(t constraint.Type) constraint.Constraint
Constraint returns requested Constraint if found.
func (MixedNode) ConstraintMap ¶
func (n MixedNode) ConstraintMap() *Constraints
ConstraintMap returns all constraints.
func (*MixedNode) DeleteConstraint ¶
func (n *MixedNode) DeleteConstraint(t constraint.Type)
func (*MixedNode) InheritedFrom ¶
func (n *MixedNode) InheritedFrom() string
func (MixedNode) NumberOfConstraints ¶
func (n MixedNode) NumberOfConstraints() int
func (MixedNode) SchemaType ¶
func (n MixedNode) SchemaType() schema.SchemaType
func (*MixedNode) SetComment ¶
func (n *MixedNode) SetComment(s string)
func (*MixedNode) SetInheritedFrom ¶
func (n *MixedNode) SetInheritedFrom(s string)
func (*MixedNode) SetJsonType ¶
SetJsonType for mixed node n.baseNode.jsonType is an EXAMPLE type
func (*MixedNode) SetRealType ¶
type MixedValueNode ¶
type MixedValueNode struct {
// contains filtered or unexported fields
}
func NewMixedValueNode ¶
func NewMixedValueNode(lex lexeme.LexEvent) *MixedValueNode
func (*MixedValueNode) AddConstraint ¶
func (n *MixedValueNode) AddConstraint(c constraint.Constraint)
func (MixedValueNode) BasisLexEventOfSchemaForNode ¶
func (MixedValueNode) Constraint ¶
func (n MixedValueNode) Constraint(t constraint.Type) constraint.Constraint
Constraint returns requested Constraint if found.
func (MixedValueNode) ConstraintMap ¶
func (n MixedValueNode) ConstraintMap() *Constraints
ConstraintMap returns all constraints.
func (*MixedValueNode) Copy ¶
func (n *MixedValueNode) Copy() Node
func (*MixedValueNode) DeleteConstraint ¶
func (n *MixedValueNode) DeleteConstraint(t constraint.Type)
func (*MixedValueNode) GetTypes ¶
func (n *MixedValueNode) GetTypes() []string
func (*MixedValueNode) InheritedFrom ¶
func (n *MixedValueNode) InheritedFrom() string
func (MixedValueNode) NumberOfConstraints ¶
func (n MixedValueNode) NumberOfConstraints() int
func (MixedValueNode) SchemaType ¶
func (n MixedValueNode) SchemaType() schema.SchemaType
func (*MixedValueNode) SetComment ¶
func (n *MixedValueNode) SetComment(s string)
func (*MixedValueNode) SetInheritedFrom ¶
func (n *MixedValueNode) SetInheritedFrom(s string)
func (*MixedValueNode) SetRealType ¶
func (*MixedValueNode) SetRealType(string) bool
type Node ¶
type Node interface { // Type returns type of this node. Type() json.Type SchemaType() schema.SchemaType SetRealType(string) bool RealType() string // Parent returns a parent of this node. Parent() Node // SetParent sets a parent for this node. SetParent(Node) // BasisLexEventOfSchemaForNode returns a LexEvent from the scheme on the // basis of which the node is created. It is used to check on the schemes for // compliance with the example and the list of constraints. Also used to display // an error. BasisLexEventOfSchemaForNode() lexeme.LexEvent // Grow this method receives the input lexical event from the scanner, fill // yourself with data from them. If necessary, creates children. Returns the // node to which you want to pass the next lexeme (yourself, child, or parent). Grow(lexeme.LexEvent) (Node, bool) // Constraint returns a constraint by its type. Constraint(constraint.Type) constraint.Constraint // AddConstraint adds a constraint to this node. AddConstraint(constraint.Constraint) // DeleteConstraint removes a constraint from this node. DeleteConstraint(constraint.Type) // ConstraintMap returns a list of constraints or nil (if empty). ConstraintMap() *Constraints // NumberOfConstraints returns the number of constraints. NumberOfConstraints() int // Value returns this node's value. Value() bytes.Bytes // ASTNode returns proper ASTNode for this node. ASTNode() (schema.ASTNode, error) // SetComment sets a comment for this node. SetComment(string) // Comment returns this node comment. Comment() string SetInheritedFrom(string) InheritedFrom() string Copy() Node }
The Node of the internal representation of the scheme. Roughly corresponds to the JSON element in the EXAMPLE of schema. Contains information about the constraints imposed on the node.
func VirtualNodeForAny ¶ added in v0.2.0
func VirtualNodeForAny() Node
type ObjectNode ¶
type ObjectNode struct {
// contains filtered or unexported fields
}
func NewObjectNode ¶
func NewObjectNode(lex lexeme.LexEvent) *ObjectNode
func (*ObjectNode) AddChild ¶
func (n *ObjectNode) AddChild(key ObjectNodeKey, child Node)
func (*ObjectNode) AddConstraint ¶
func (n *ObjectNode) AddConstraint(c constraint.Constraint)
AddConstraint adds new constraint to this node. Won't add if c is nil.
func (*ObjectNode) AddKey ¶
func (n *ObjectNode) AddKey(key string, isShortcut bool, lex lexeme.LexEvent)
func (ObjectNode) BasisLexEventOfSchemaForNode ¶
func (*ObjectNode) Child ¶
func (n *ObjectNode) Child(key string, isShortcut bool) (Node, bool)
Child returns child bye specified key.
func (*ObjectNode) ChildByRawKey ¶
func (n *ObjectNode) ChildByRawKey(rawKey bytes.Bytes) (Node, bool)
ChildByRawKey returns child by raw key as is present in schema. For instance: "foo" or @foo (shortcut).
func (*ObjectNode) Children ¶
func (n *ObjectNode) Children() []Node
func (ObjectNode) Constraint ¶
func (n ObjectNode) Constraint(t constraint.Type) constraint.Constraint
Constraint returns requested Constraint if found.
func (ObjectNode) ConstraintMap ¶
func (n ObjectNode) ConstraintMap() *Constraints
ConstraintMap returns all constraints.
func (*ObjectNode) Copy ¶
func (n *ObjectNode) Copy() Node
func (*ObjectNode) CopyAndLowercaseKeys ¶ added in v0.2.0
func (n *ObjectNode) CopyAndLowercaseKeys() *ObjectNode
func (*ObjectNode) DeleteConstraint ¶
func (n *ObjectNode) DeleteConstraint(t constraint.Type)
func (*ObjectNode) EnsureAdditionalProperties ¶ added in v0.2.0
func (n *ObjectNode) EnsureAdditionalProperties()
func (*ObjectNode) InheritedFrom ¶
func (n *ObjectNode) InheritedFrom() string
func (*ObjectNode) Key ¶
func (n *ObjectNode) Key(index int) ObjectNodeKey
func (*ObjectNode) Keys ¶
func (n *ObjectNode) Keys() *ObjectNodeKeys
func (*ObjectNode) Len ¶
func (n *ObjectNode) Len() int
func (ObjectNode) NumberOfConstraints ¶
func (n ObjectNode) NumberOfConstraints() int
func (ObjectNode) SchemaType ¶
func (n ObjectNode) SchemaType() schema.SchemaType
func (*ObjectNode) SetComment ¶
func (n *ObjectNode) SetComment(s string)
func (*ObjectNode) SetInheritedFrom ¶
func (n *ObjectNode) SetInheritedFrom(s string)
func (*ObjectNode) SetRealType ¶
func (*ObjectNode) Type ¶
func (*ObjectNode) Type() json.Type
type ObjectNodeKey ¶
type ObjectNodeKeys ¶
type ObjectNodeKeys struct { Data []ObjectNodeKey // contains filtered or unexported fields }
func (ObjectNodeKeys) Find ¶
func (k ObjectNodeKeys) Find(i int) (ObjectNodeKey, bool)
func (ObjectNodeKeys) Get ¶
func (k ObjectNodeKeys) Get(key string, isShortcut bool) (ObjectNodeKey, bool)
func (*ObjectNodeKeys) Set ¶
func (k *ObjectNodeKeys) Set(v ObjectNodeKey)