Documentation ¶
Index ¶
- Constants
- func NewMismatchedTypeAssertionError(foundNode yamlmeta.Node, expectedType Type) error
- func NewSchemaError(summary string, errs ...error) error
- func NewUnexpectedKeyAssertionError(found *yamlmeta.MapItem, definition *filepos.Position, allowedKeys []string) error
- func SetType(n yamlmeta.Node, t Type)
- type Annotation
- type AnyType
- func (a AnyType) AssignTypeTo(yamlmeta.Node) TypeCheck
- func (a AnyType) CheckType(node yamlmeta.Node) TypeCheck
- func (a AnyType) GetDefaultValue() interface{}
- func (a AnyType) GetDefinitionPosition() *filepos.Position
- func (a *AnyType) GetDescription() string
- func (a *AnyType) GetExamples() []Example
- func (a *AnyType) GetTitle() string
- func (a AnyType) GetValueType() Type
- func (a *AnyType) IsDeprecated() (bool, string)
- func (a *AnyType) SetDefaultValue(val interface{})
- func (a *AnyType) SetDeprecated(deprecated bool, notice string)
- func (a *AnyType) SetDescription(desc string)
- func (a *AnyType) SetExamples(exs []Example)
- func (a *AnyType) SetTitle(title string)
- func (a AnyType) String() string
- type ArrayItemType
- func (a *ArrayItemType) AssignTypeTo(node yamlmeta.Node) TypeCheck
- func (a *ArrayItemType) CheckType(node yamlmeta.Node) TypeCheck
- func (a ArrayItemType) GetDefaultValue() interface{}
- func (a ArrayItemType) GetDefinitionPosition() *filepos.Position
- func (a *ArrayItemType) GetDescription() string
- func (a *ArrayItemType) GetExamples() []Example
- func (a *ArrayItemType) GetTitle() string
- func (a ArrayItemType) GetValueType() Type
- func (a *ArrayItemType) IsDeprecated() (bool, string)
- func (a *ArrayItemType) SetDefaultValue(val interface{})
- func (a *ArrayItemType) SetDeprecated(deprecated bool, notice string)
- func (a *ArrayItemType) SetDescription(desc string)
- func (a *ArrayItemType) SetExamples(exs []Example)
- func (a *ArrayItemType) SetTitle(title string)
- func (a ArrayItemType) String() string
- type ArrayType
- func (a *ArrayType) AssignTypeTo(node yamlmeta.Node) TypeCheck
- func (a *ArrayType) CheckType(node yamlmeta.Node) TypeCheck
- func (a ArrayType) GetDefaultValue() interface{}
- func (a ArrayType) GetDefinitionPosition() *filepos.Position
- func (a *ArrayType) GetDescription() string
- func (a *ArrayType) GetExamples() []Example
- func (a *ArrayType) GetTitle() string
- func (a ArrayType) GetValueType() Type
- func (a *ArrayType) IsDeprecated() (bool, string)
- func (a *ArrayType) SetDefaultValue(val interface{})
- func (a *ArrayType) SetDeprecated(deprecated bool, notice string)
- func (a *ArrayType) SetDescription(desc string)
- func (a *ArrayType) SetExamples(exs []Example)
- func (a *ArrayType) SetTitle(title string)
- func (a ArrayType) String() string
- type DefaultAnnotation
- type DeprecatedAnnotation
- type DescriptionAnnotation
- type DocumentType
- func (t *DocumentType) AssignTypeTo(node yamlmeta.Node) TypeCheck
- func (t *DocumentType) CheckType(node yamlmeta.Node) TypeCheck
- func (t DocumentType) GetDefaultValue() interface{}
- func (t *DocumentType) GetDefinitionPosition() *filepos.Position
- func (t *DocumentType) GetDescription() string
- func (t *DocumentType) GetExamples() []Example
- func (t *DocumentType) GetTitle() string
- func (t *DocumentType) GetValueType() Type
- func (t *DocumentType) IsDeprecated() (bool, string)
- func (t *DocumentType) SetDefaultValue(val interface{})
- func (t *DocumentType) SetDeprecated(deprecated bool, notice string)
- func (t *DocumentType) SetDescription(desc string)
- func (t *DocumentType) SetExamples(data []Example)
- func (t *DocumentType) SetTitle(title string)
- func (t *DocumentType) String() string
- type Example
- type ExampleAnnotation
- type MapItemType
- func (t *MapItemType) AssignTypeTo(node yamlmeta.Node) TypeCheck
- func (t *MapItemType) CheckType(node yamlmeta.Node) TypeCheck
- func (t MapItemType) GetDefaultValue() interface{}
- func (t MapItemType) GetDefinitionPosition() *filepos.Position
- func (t *MapItemType) GetDescription() string
- func (t *MapItemType) GetExamples() []Example
- func (t *MapItemType) GetTitle() string
- func (t MapItemType) GetValueType() Type
- func (t *MapItemType) IsDeprecated() (bool, string)
- func (t *MapItemType) SetDefaultValue(val interface{})
- func (t *MapItemType) SetDeprecated(deprecated bool, notice string)
- func (t *MapItemType) SetDescription(desc string)
- func (t *MapItemType) SetExamples(exs []Example)
- func (t *MapItemType) SetTitle(title string)
- func (t MapItemType) String() string
- type MapType
- func (m *MapType) AllowedKeys() []string
- func (m *MapType) AllowsKey(key interface{}) bool
- func (m *MapType) AssignTypeTo(node yamlmeta.Node) TypeCheck
- func (m *MapType) CheckType(node yamlmeta.Node) TypeCheck
- func (m MapType) GetDefaultValue() interface{}
- func (m MapType) GetDefinitionPosition() *filepos.Position
- func (m *MapType) GetDescription() string
- func (m *MapType) GetExamples() []Example
- func (m *MapType) GetTitle() string
- func (m MapType) GetValueType() Type
- func (m *MapType) IsDeprecated() (bool, string)
- func (m *MapType) SetDefaultValue(val interface{})
- func (m *MapType) SetDeprecated(deprecated bool, notice string)
- func (m *MapType) SetDescription(desc string)
- func (m *MapType) SetExamples(exs []Example)
- func (m *MapType) SetTitle(title string)
- func (m MapType) String() string
- type NullType
- func (n NullType) AssignTypeTo(node yamlmeta.Node) TypeCheck
- func (n NullType) CheckType(node yamlmeta.Node) TypeCheck
- func (n NullType) GetDefaultValue() interface{}
- func (n NullType) GetDefinitionPosition() *filepos.Position
- func (n *NullType) GetDescription() string
- func (n *NullType) GetExamples() []Example
- func (n *NullType) GetTitle() string
- func (n NullType) GetValueType() Type
- func (n *NullType) IsDeprecated() (bool, string)
- func (n *NullType) SetDefaultValue(val interface{})
- func (n *NullType) SetDeprecated(deprecated bool, notice string)
- func (n *NullType) SetDescription(desc string)
- func (n *NullType) SetExamples(exs []Example)
- func (n *NullType) SetTitle(title string)
- func (n NullType) String() string
- type NullableAnnotation
- type OpenAPIDocument
- type ScalarType
- func (s *ScalarType) AssignTypeTo(node yamlmeta.Node) TypeCheck
- func (s *ScalarType) CheckType(node yamlmeta.Node) TypeCheck
- func (s ScalarType) GetDefaultValue() interface{}
- func (s ScalarType) GetDefinitionPosition() *filepos.Position
- func (s *ScalarType) GetDescription() string
- func (s *ScalarType) GetExamples() []Example
- func (s *ScalarType) GetTitle() string
- func (s ScalarType) GetValueType() Type
- func (s *ScalarType) IsDeprecated() (bool, string)
- func (s *ScalarType) SetDefaultValue(val interface{})
- func (s *ScalarType) SetDeprecated(deprecated bool, notice string)
- func (s *ScalarType) SetDescription(desc string)
- func (s *ScalarType) SetExamples(exs []Example)
- func (s *ScalarType) SetTitle(title string)
- func (s ScalarType) String() string
- type TitleAnnotation
- type Type
- type TypeAnnotation
- type TypeCheck
Constants ¶
const ( AnnotationNullable template.AnnotationName = "schema/nullable" AnnotationType template.AnnotationName = "schema/type" AnnotationDefault template.AnnotationName = "schema/default" AnnotationDescription template.AnnotationName = "schema/desc" AnnotationTitle template.AnnotationName = "schema/title" AnnotationExamples template.AnnotationName = "schema/examples" AnnotationDeprecated template.AnnotationName = "schema/deprecated" TypeAnnotationKwargAny string = "any" )
const ( FloatType = float64(0) StringType = "" IntType = int64(0) BoolType = false )
The total set of supported scalars.
Variables ¶
This section is empty.
Functions ¶
func NewMismatchedTypeAssertionError ¶ added in v0.35.0
NewMismatchedTypeAssertionError generates an error given that `foundNode` is not of the `expectedType`.
func NewSchemaError ¶ added in v0.35.0
func NewUnexpectedKeyAssertionError ¶ added in v0.35.0
func NewUnexpectedKeyAssertionError(found *yamlmeta.MapItem, definition *filepos.Position, allowedKeys []string) error
NewUnexpectedKeyAssertionError generates a schema assertion error including the context (and hints) needed to report it to the user
Types ¶
type Annotation ¶ added in v0.34.0
type AnyType ¶ added in v0.34.0
func (AnyType) AssignTypeTo ¶ added in v0.34.0
AssignTypeTo is a no-op given that AnyType allows all types.
func (AnyType) CheckType ¶ added in v0.34.0
CheckType is a no-op because AnyType allows any value.
Always returns an empty TypeCheck.
func (AnyType) GetDefaultValue ¶ added in v0.35.0
func (a AnyType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (AnyType) GetDefinitionPosition ¶ added in v0.35.0
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*AnyType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (*AnyType) GetExamples ¶ added in v0.39.0
GetExamples provides descriptive example information
func (AnyType) GetValueType ¶ added in v0.34.0
GetValueType provides the type of the value
func (*AnyType) IsDeprecated ¶ added in v0.39.0
IsDeprecated provides deprecated field information
func (*AnyType) SetDefaultValue ¶ added in v0.38.0
func (a *AnyType) SetDefaultValue(val interface{})
SetDefaultValue does nothing
func (*AnyType) SetDeprecated ¶ added in v0.39.0
SetDeprecated sets the deprecated field value
func (*AnyType) SetDescription ¶ added in v0.38.0
SetDescription sets the description of the type
func (*AnyType) SetExamples ¶ added in v0.39.0
SetExamples sets the description and example of the type
type ArrayItemType ¶
type ArrayItemType struct { ValueType Type Position *filepos.Position // contains filtered or unexported fields }
func NewArrayItemType ¶
func NewArrayItemType(item *yamlmeta.ArrayItem) (*ArrayItemType, error)
func (*ArrayItemType) AssignTypeTo ¶
func (a *ArrayItemType) AssignTypeTo(node yamlmeta.Node) TypeCheck
AssignTypeTo assigns this schema metadata to `node`.
If `node` is not a yamlmeta.ArrayItem, `chk` contains a violation describing the mismatch If `node`'s value is not of the same structure (i.e. yamlmeta.Node type), `chk` contains a violation describing this mismatch
func (*ArrayItemType) CheckType ¶
func (a *ArrayItemType) CheckType(node yamlmeta.Node) TypeCheck
CheckType checks the type of `node` against this ArrayItemType.
If `node` is not a yamlmeta.ArrayItem, `chk` contains a violation describing this mismatch If this array item's value is a scalar, checks its type against this ArrayItemType.ValueType
func (ArrayItemType) GetDefaultValue ¶ added in v0.35.0
func (a ArrayItemType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (ArrayItemType) GetDefinitionPosition ¶ added in v0.35.0
func (a ArrayItemType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*ArrayItemType) GetDescription ¶ added in v0.38.0
func (a *ArrayItemType) GetDescription() string
GetDescription provides descriptive information
func (*ArrayItemType) GetExamples ¶ added in v0.39.0
func (a *ArrayItemType) GetExamples() []Example
GetExamples provides descriptive example information
func (*ArrayItemType) GetTitle ¶ added in v0.39.0
func (a *ArrayItemType) GetTitle() string
GetTitle provides title information
func (ArrayItemType) GetValueType ¶
func (a ArrayItemType) GetValueType() Type
GetValueType provides the type of the value
func (*ArrayItemType) IsDeprecated ¶ added in v0.39.0
func (a *ArrayItemType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*ArrayItemType) SetDefaultValue ¶ added in v0.38.0
func (a *ArrayItemType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ArrayItemType) SetDeprecated ¶ added in v0.39.0
func (a *ArrayItemType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*ArrayItemType) SetDescription ¶ added in v0.38.0
func (a *ArrayItemType) SetDescription(desc string)
SetDescription sets the description of the type
func (*ArrayItemType) SetExamples ¶ added in v0.39.0
func (a *ArrayItemType) SetExamples(exs []Example)
SetExamples sets the description and example of the type
func (*ArrayItemType) SetTitle ¶ added in v0.39.0
func (a *ArrayItemType) SetTitle(title string)
SetTitle sets the title of the type
func (ArrayItemType) String ¶ added in v0.32.0
func (a ArrayItemType) String() string
String produces a user-friendly name of the expected type.
type ArrayType ¶
type ArrayType struct { ItemsType Type Position *filepos.Position // contains filtered or unexported fields }
func (*ArrayType) AssignTypeTo ¶
AssignTypeTo assigns this schema metadata to `node`.
If `node` is not a yamlmeta.Array, `chk` contains a violation describing the mismatch For each `node`'s yamlmeta.ArrayItem's that cannot be assigned this ArrayType's ArrayItemType, `chk` contains a violation describing the mismatch
func (*ArrayType) CheckType ¶
CheckType checks the type of `node` against this ArrayType
If `node` is not a yamlmeta.Array, `chk` contains a violation describing the mismatch
func (ArrayType) GetDefaultValue ¶ added in v0.35.0
func (a ArrayType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (ArrayType) GetDefinitionPosition ¶ added in v0.35.0
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*ArrayType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (*ArrayType) GetExamples ¶ added in v0.39.0
GetExamples provides descriptive example information
func (ArrayType) GetValueType ¶
GetValueType provides the type of the value
func (*ArrayType) IsDeprecated ¶ added in v0.39.0
IsDeprecated provides deprecated field information
func (*ArrayType) SetDefaultValue ¶ added in v0.38.0
func (a *ArrayType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ArrayType) SetDeprecated ¶ added in v0.39.0
SetDeprecated sets the deprecated field value
func (*ArrayType) SetDescription ¶ added in v0.38.0
SetDescription sets the description of the type
func (*ArrayType) SetExamples ¶ added in v0.39.0
SetExamples sets the description and example of the type
type DefaultAnnotation ¶ added in v0.38.0
type DefaultAnnotation struct {
// contains filtered or unexported fields
}
DefaultAnnotation is a wrapper for a value provided via @schema/default annotation
func NewDefaultAnnotation ¶ added in v0.38.0
func NewDefaultAnnotation(ann template.NodeAnnotation, effectiveType Type, pos *filepos.Position) (*DefaultAnnotation, error)
NewDefaultAnnotation checks the argument provided via @schema/default annotation, and returns wrapper for that value.
func (*DefaultAnnotation) GetPosition ¶ added in v0.39.0
func (d *DefaultAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*DefaultAnnotation) NewTypeFromAnn ¶ added in v0.38.0
func (d *DefaultAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation.
func (*DefaultAnnotation) Val ¶ added in v0.38.0
func (d *DefaultAnnotation) Val() interface{}
Val returns default value specified in annotation.
type DeprecatedAnnotation ¶ added in v0.39.0
type DeprecatedAnnotation struct {
// contains filtered or unexported fields
}
DeprecatedAnnotation is a wrapper for a value provided via @schema/deprecated annotation
func NewDeprecatedAnnotation ¶ added in v0.39.0
func NewDeprecatedAnnotation(ann template.NodeAnnotation, pos *filepos.Position) (*DeprecatedAnnotation, error)
NewDeprecatedAnnotation validates the value from the AnnotationDeprecated, and returns the value
func (*DeprecatedAnnotation) GetPosition ¶ added in v0.39.0
func (d *DeprecatedAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*DeprecatedAnnotation) NewTypeFromAnn ¶ added in v0.39.0
func (d *DeprecatedAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation. DeprecatedAnnotation has no type information.
type DescriptionAnnotation ¶ added in v0.38.0
type DescriptionAnnotation struct {
// contains filtered or unexported fields
}
DescriptionAnnotation documents the purpose of a node
func NewDescriptionAnnotation ¶ added in v0.38.0
func NewDescriptionAnnotation(ann template.NodeAnnotation, pos *filepos.Position) (*DescriptionAnnotation, error)
NewDescriptionAnnotation validates the value from the AnnotationDescription, and returns the value
func (*DescriptionAnnotation) GetPosition ¶ added in v0.39.0
func (d *DescriptionAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*DescriptionAnnotation) NewTypeFromAnn ¶ added in v0.38.0
func (d *DescriptionAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation. DescriptionAnnotation has no type information.
type DocumentType ¶
type DocumentType struct { Source *yamlmeta.Document ValueType Type // typically one of: MapType, ArrayType, ScalarType Position *filepos.Position // contains filtered or unexported fields }
func NewDocumentType ¶ added in v0.32.0
func NewDocumentType(doc *yamlmeta.Document) (*DocumentType, error)
NewDocumentType constructs a complete DocumentType based on the contents of a schema YAML document.
func (*DocumentType) AssignTypeTo ¶
func (t *DocumentType) AssignTypeTo(node yamlmeta.Node) TypeCheck
AssignTypeTo assigns this schema metadata to `node`.
If `node` is not a yamlmeta.Document, `chk` contains a violation describing the mismatch If `node`'s value is not of the same structure (i.e. yamlmeta.Node type), `chk` contains a violation describing this mismatch
func (*DocumentType) CheckType ¶
func (t *DocumentType) CheckType(node yamlmeta.Node) TypeCheck
CheckType checks the type of `node` against this DocumentType.
If `node` is not a yamlmeta.Document, `chk` contains a violation describing this mismatch If this document's value is a scalar, checks its type against this DocumentType.ValueType
func (DocumentType) GetDefaultValue ¶ added in v0.35.0
func (t DocumentType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (*DocumentType) GetDefinitionPosition ¶ added in v0.35.0
func (t *DocumentType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*DocumentType) GetDescription ¶ added in v0.38.0
func (t *DocumentType) GetDescription() string
GetDescription provides descriptive information
func (*DocumentType) GetExamples ¶ added in v0.39.0
func (t *DocumentType) GetExamples() []Example
GetExamples provides descriptive example information
func (*DocumentType) GetTitle ¶ added in v0.39.0
func (t *DocumentType) GetTitle() string
GetTitle provides title information
func (*DocumentType) GetValueType ¶
func (t *DocumentType) GetValueType() Type
GetValueType provides the type of the value
func (*DocumentType) IsDeprecated ¶ added in v0.39.0
func (t *DocumentType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*DocumentType) SetDefaultValue ¶ added in v0.38.0
func (t *DocumentType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value of the entire document to `val`
func (*DocumentType) SetDeprecated ¶ added in v0.39.0
func (t *DocumentType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*DocumentType) SetDescription ¶ added in v0.38.0
func (t *DocumentType) SetDescription(desc string)
SetDescription sets the description of the type
func (*DocumentType) SetExamples ¶ added in v0.39.0
func (t *DocumentType) SetExamples(data []Example)
SetExamples sets the description and example of the type
func (*DocumentType) SetTitle ¶ added in v0.39.0
func (t *DocumentType) SetTitle(title string)
SetTitle sets the title of the type
func (*DocumentType) String ¶ added in v0.32.0
func (t *DocumentType) String() string
String produces a user-friendly name of the expected type.
type Example ¶ added in v0.39.0
type Example struct {
// contains filtered or unexported fields
}
Example contains a yaml example and its description
type ExampleAnnotation ¶ added in v0.39.0
type ExampleAnnotation struct {
// contains filtered or unexported fields
}
ExampleAnnotation provides the Examples of a node
func NewExampleAnnotation ¶ added in v0.39.0
func NewExampleAnnotation(ann template.NodeAnnotation, pos *filepos.Position) (*ExampleAnnotation, error)
NewExampleAnnotation validates the value(s) from the AnnotationExamples, and returns the value(s)
func (*ExampleAnnotation) GetPosition ¶ added in v0.39.0
func (e *ExampleAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*ExampleAnnotation) NewTypeFromAnn ¶ added in v0.39.0
func (e *ExampleAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation.
type MapItemType ¶
type MapItemType struct { Key interface{} // usually a string ValueType Type Position *filepos.Position // contains filtered or unexported fields }
func NewMapItemType ¶
func NewMapItemType(item *yamlmeta.MapItem) (*MapItemType, error)
func (*MapItemType) AssignTypeTo ¶
func (t *MapItemType) AssignTypeTo(node yamlmeta.Node) TypeCheck
AssignTypeTo assigns this schema metadata to `node`.
If `node` is not a yamlmeta.MapItem, `chk` contains a violation describing the mismatch If `node`'s value is not of the same structure (i.e. yamlmeta.Node type), `chk` contains a violation describing this mismatch
func (*MapItemType) CheckType ¶
func (t *MapItemType) CheckType(node yamlmeta.Node) TypeCheck
CheckType checks the type of `node` against this MapItemType.
If `node` is not a yamlmeta.MapItem, `chk` contains a violation describing this mismatch If this map item's value is a scalar, checks its type against this MapItemType.ValueType
func (MapItemType) GetDefaultValue ¶ added in v0.35.0
func (t MapItemType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (MapItemType) GetDefinitionPosition ¶ added in v0.35.0
func (t MapItemType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*MapItemType) GetDescription ¶ added in v0.38.0
func (t *MapItemType) GetDescription() string
GetDescription provides descriptive information
func (*MapItemType) GetExamples ¶ added in v0.39.0
func (t *MapItemType) GetExamples() []Example
GetExamples provides descriptive example information
func (*MapItemType) GetTitle ¶ added in v0.39.0
func (t *MapItemType) GetTitle() string
GetTitle provides title information
func (MapItemType) GetValueType ¶
func (t MapItemType) GetValueType() Type
GetValueType provides the type of the value
func (*MapItemType) IsDeprecated ¶ added in v0.39.0
func (t *MapItemType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*MapItemType) SetDefaultValue ¶ added in v0.38.0
func (t *MapItemType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*MapItemType) SetDeprecated ¶ added in v0.39.0
func (t *MapItemType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*MapItemType) SetDescription ¶ added in v0.38.0
func (t *MapItemType) SetDescription(desc string)
SetDescription sets the description of the type
func (*MapItemType) SetExamples ¶ added in v0.39.0
func (t *MapItemType) SetExamples(exs []Example)
SetExamples sets the description and example of the type
func (*MapItemType) SetTitle ¶ added in v0.39.0
func (t *MapItemType) SetTitle(title string)
SetTitle sets the title of the type
func (MapItemType) String ¶ added in v0.32.0
func (t MapItemType) String() string
String produces a user-friendly name of the expected type.
type MapType ¶
type MapType struct { Items []*MapItemType Position *filepos.Position // contains filtered or unexported fields }
func (*MapType) AllowedKeys ¶ added in v0.38.0
AllowedKeys returns the set of keys (in string format) permitted in this map.
func (*MapType) AllowsKey ¶
AllowsKey determines whether this MapType permits a MapItem with the key of `key`
func (*MapType) AssignTypeTo ¶
AssignTypeTo assigns this schema metadata to `node`.
If `node` is not a yamlmeta.Map, `chk` contains a violation describing the mismatch If `node`'s yamlmeta.MapItem's cannot be assigned their corresponding MapItemType, `chk` contains a violation describing the mismatch If `node` is missing any yamlmeta.MapItem's specified in this MapType, they are added to `node`.
func (*MapType) CheckType ¶
CheckType checks the type of `node` against this MapType.
If `node` is not a yamlmeta.Map, `chk` contains a violation describing this mismatch If a contained yamlmeta.MapItem is not allowed by this MapType, `chk` contains a corresponding violation
func (MapType) GetDefaultValue ¶ added in v0.35.0
func (m MapType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (MapType) GetDefinitionPosition ¶ added in v0.35.0
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*MapType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (*MapType) GetExamples ¶ added in v0.39.0
GetExamples provides descriptive example information
func (MapType) GetValueType ¶
GetValueType provides the type of the value
func (*MapType) IsDeprecated ¶ added in v0.39.0
IsDeprecated provides deprecated field information
func (*MapType) SetDefaultValue ¶ added in v0.38.0
func (m *MapType) SetDefaultValue(val interface{})
SetDefaultValue is ignored as default values should be set on each MapItemType, individually.
func (*MapType) SetDeprecated ¶ added in v0.39.0
SetDeprecated sets the deprecated field value
func (*MapType) SetDescription ¶ added in v0.38.0
SetDescription sets the description of the type
func (*MapType) SetExamples ¶ added in v0.39.0
SetExamples sets the description and example of the type
type NullType ¶ added in v0.34.0
type NullType struct { ValueType Type Position *filepos.Position // contains filtered or unexported fields }
func (NullType) AssignTypeTo ¶ added in v0.34.0
AssignTypeTo assigns this NullType's wrapped Type to `node`.
func (NullType) CheckType ¶ added in v0.34.0
CheckType checks the type of `node` against this NullType
If `node`'s value is null, this check passes If `node`'s value is not null, then it is checked against this NullType's wrapped Type.
func (NullType) GetDefaultValue ¶ added in v0.35.0
func (n NullType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (NullType) GetDefinitionPosition ¶ added in v0.35.0
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*NullType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (*NullType) GetExamples ¶ added in v0.39.0
GetExamples provides descriptive example information
func (NullType) GetValueType ¶ added in v0.34.0
GetValueType provides the type of the value
func (*NullType) IsDeprecated ¶ added in v0.39.0
IsDeprecated provides deprecated field information
func (*NullType) SetDefaultValue ¶ added in v0.38.0
func (n *NullType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value of the wrapped type to `val`
func (*NullType) SetDeprecated ¶ added in v0.39.0
SetDeprecated sets the deprecated field value
func (*NullType) SetDescription ¶ added in v0.38.0
SetDescription sets the description of the type
func (*NullType) SetExamples ¶ added in v0.39.0
SetExamples sets the description and example of the type
type NullableAnnotation ¶ added in v0.34.0
type NullableAnnotation struct {
// contains filtered or unexported fields
}
func NewNullableAnnotation ¶ added in v0.34.0
func NewNullableAnnotation(ann template.NodeAnnotation, node yamlmeta.Node) (*NullableAnnotation, error)
NewNullableAnnotation checks that there are no arguments, and returns wrapper for the annotated node.
func (*NullableAnnotation) GetPosition ¶ added in v0.39.0
func (n *NullableAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*NullableAnnotation) NewTypeFromAnn ¶ added in v0.34.0
func (n *NullableAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation.
type OpenAPIDocument ¶ added in v0.38.0
type OpenAPIDocument struct {
// contains filtered or unexported fields
}
OpenAPIDocument holds the document type used for creating an OpenAPI document
func NewOpenAPIDocument ¶ added in v0.38.0
func NewOpenAPIDocument(docType *DocumentType) *OpenAPIDocument
NewOpenAPIDocument creates an instance of an OpenAPIDocument based on the given DocumentType
func (*OpenAPIDocument) AsDocument ¶ added in v0.38.0
func (o *OpenAPIDocument) AsDocument() *yamlmeta.Document
AsDocument generates a new AST of this OpenAPI v3.0.x document, populating the `schemas:` section with the type information contained in `docType`.
type ScalarType ¶
type ScalarType struct { ValueType interface{} Position *filepos.Position // contains filtered or unexported fields }
func (*ScalarType) AssignTypeTo ¶
func (s *ScalarType) AssignTypeTo(node yamlmeta.Node) TypeCheck
AssignTypeTo returns a violation describing the type mismatch, given that ScalarType will never accept a yamlmeta.Node
func (*ScalarType) CheckType ¶
func (s *ScalarType) CheckType(node yamlmeta.Node) TypeCheck
CheckType checks the type of `node`'s `value`, which is expected to be a scalar type.
If the value is not a recognized scalar type, `chk` contains a corresponding violation If the value is not of the type specified in this ScalarType, `chk` contains a violation describing the mismatch
func (ScalarType) GetDefaultValue ¶ added in v0.35.0
func (s ScalarType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (ScalarType) GetDefinitionPosition ¶ added in v0.35.0
func (s ScalarType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*ScalarType) GetDescription ¶ added in v0.38.0
func (s *ScalarType) GetDescription() string
GetDescription provides descriptive information
func (*ScalarType) GetExamples ¶ added in v0.39.0
func (s *ScalarType) GetExamples() []Example
GetExamples provides descriptive example information
func (*ScalarType) GetTitle ¶ added in v0.39.0
func (s *ScalarType) GetTitle() string
GetTitle provides title information
func (ScalarType) GetValueType ¶
func (s ScalarType) GetValueType() Type
GetValueType provides the type of the value
func (*ScalarType) IsDeprecated ¶ added in v0.39.0
func (s *ScalarType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*ScalarType) SetDefaultValue ¶ added in v0.38.0
func (s *ScalarType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ScalarType) SetDeprecated ¶ added in v0.39.0
func (s *ScalarType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*ScalarType) SetDescription ¶ added in v0.38.0
func (s *ScalarType) SetDescription(desc string)
SetDescription sets the description of the type
func (*ScalarType) SetExamples ¶ added in v0.39.0
func (s *ScalarType) SetExamples(exs []Example)
SetExamples sets the description and example of the type
func (*ScalarType) SetTitle ¶ added in v0.39.0
func (s *ScalarType) SetTitle(title string)
SetTitle sets the title of the type
func (ScalarType) String ¶ added in v0.32.0
func (s ScalarType) String() string
String produces a user-friendly name of the expected type.
type TitleAnnotation ¶ added in v0.39.0
type TitleAnnotation struct {
// contains filtered or unexported fields
}
TitleAnnotation provides title of a node
func NewTitleAnnotation ¶ added in v0.39.0
func NewTitleAnnotation(ann template.NodeAnnotation, pos *filepos.Position) (*TitleAnnotation, error)
NewTitleAnnotation validates the value from the AnnotationTitle, and returns the value
func (*TitleAnnotation) GetPosition ¶ added in v0.39.0
func (t *TitleAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*TitleAnnotation) NewTypeFromAnn ¶ added in v0.39.0
func (t *TitleAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation. TitleAnnotation has no type information.
type Type ¶ added in v0.39.0
type Type interface { AssignTypeTo(node yamlmeta.Node) TypeCheck CheckType(node yamlmeta.Node) TypeCheck GetValueType() Type GetDefaultValue() interface{} SetDefaultValue(interface{}) GetDefinitionPosition() *filepos.Position GetDescription() string SetDescription(string) GetTitle() string SetTitle(string) GetExamples() []Example SetExamples([]Example) IsDeprecated() (bool, string) SetDeprecated(bool, string) String() string }
Type encapsulates a schema that describes a yamlmeta.Node.
type TypeAnnotation ¶ added in v0.34.0
type TypeAnnotation struct {
// contains filtered or unexported fields
}
func NewTypeAnnotation ¶ added in v0.34.0
func NewTypeAnnotation(ann template.NodeAnnotation, node yamlmeta.Node) (*TypeAnnotation, error)
NewTypeAnnotation checks the keyword argument provided via @schema/type annotation, and returns wrapper for the annotated node.
func (*TypeAnnotation) GetPosition ¶ added in v0.39.0
func (t *TypeAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*TypeAnnotation) IsAny ¶ added in v0.34.0
func (t *TypeAnnotation) IsAny() bool
func (*TypeAnnotation) NewTypeFromAnn ¶ added in v0.34.0
func (t *TypeAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation.
type TypeCheck ¶ added in v0.39.0
type TypeCheck struct {
Violations []error
}
TypeCheck is the result of checking a yamlmeta.Node structure against a given Type, recursively.
func CheckNode ¶ added in v0.39.0
CheckNode attempts type check of root node and its children.
If `n` has "schema/type" metadata (typically attached using SetType()), `n` is checked against that schema, recursively. `chk` contains all the type violations found in the check.
func (TypeCheck) Error ¶ added in v0.39.0
Error generates the error message composed of the total set of TypeCheck.Violations.
func (*TypeCheck) HasViolations ¶ added in v0.39.0
HasViolations indicates whether this TypeCheck contains any violations.