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 ¶
NewMismatchedTypeAssertionError generates an error given that `foundNode` is not of the `expectedType`.
func NewSchemaError ¶
Types ¶
type Annotation ¶
type AnyType ¶
func (AnyType) AssignTypeTo ¶
AssignTypeTo is a no-op given that AnyType allows all types.
func (AnyType) CheckType ¶
CheckType is a no-op because AnyType allows any value.
Always returns an empty TypeCheck.
func (AnyType) GetDefaultValue ¶
func (a AnyType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (AnyType) GetDefinitionPosition ¶
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*AnyType) GetDescription ¶
GetDescription provides descriptive information
func (*AnyType) GetExamples ¶
GetExamples provides descriptive example information
func (AnyType) GetValueType ¶
GetValueType provides the type of the value
func (*AnyType) IsDeprecated ¶
IsDeprecated provides deprecated field information
func (*AnyType) SetDefaultValue ¶
func (a *AnyType) SetDefaultValue(val interface{})
SetDefaultValue does nothing
func (*AnyType) SetDeprecated ¶
SetDeprecated sets the deprecated field value
func (*AnyType) SetDescription ¶
SetDescription sets the description of the type
func (*AnyType) SetExamples ¶
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 ¶
func (a ArrayItemType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (ArrayItemType) GetDefinitionPosition ¶
func (a ArrayItemType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*ArrayItemType) GetDescription ¶
func (a *ArrayItemType) GetDescription() string
GetDescription provides descriptive information
func (*ArrayItemType) GetExamples ¶
func (a *ArrayItemType) GetExamples() []Example
GetExamples provides descriptive example information
func (*ArrayItemType) GetTitle ¶
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 ¶
func (a *ArrayItemType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*ArrayItemType) SetDefaultValue ¶
func (a *ArrayItemType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ArrayItemType) SetDeprecated ¶
func (a *ArrayItemType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*ArrayItemType) SetDescription ¶
func (a *ArrayItemType) SetDescription(desc string)
SetDescription sets the description of the type
func (*ArrayItemType) SetExamples ¶
func (a *ArrayItemType) SetExamples(exs []Example)
SetExamples sets the description and example of the type
func (*ArrayItemType) SetTitle ¶
func (a *ArrayItemType) SetTitle(title string)
SetTitle sets the title of the type
func (ArrayItemType) String ¶
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 ¶
func (a ArrayType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (ArrayType) GetDefinitionPosition ¶
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*ArrayType) GetDescription ¶
GetDescription provides descriptive information
func (*ArrayType) GetExamples ¶
GetExamples provides descriptive example information
func (ArrayType) GetValueType ¶
GetValueType provides the type of the value
func (*ArrayType) IsDeprecated ¶
IsDeprecated provides deprecated field information
func (*ArrayType) SetDefaultValue ¶
func (a *ArrayType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ArrayType) SetDeprecated ¶
SetDeprecated sets the deprecated field value
func (*ArrayType) SetDescription ¶
SetDescription sets the description of the type
func (*ArrayType) SetExamples ¶
SetExamples sets the description and example of the type
type DefaultAnnotation ¶
type DefaultAnnotation struct {
// contains filtered or unexported fields
}
DefaultAnnotation is a wrapper for a value provided via @schema/default annotation
func NewDefaultAnnotation ¶
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 ¶
func (d *DefaultAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*DefaultAnnotation) NewTypeFromAnn ¶
func (d *DefaultAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation.
func (*DefaultAnnotation) Val ¶
func (d *DefaultAnnotation) Val() interface{}
Val returns default value specified in annotation.
type DeprecatedAnnotation ¶
type DeprecatedAnnotation struct {
// contains filtered or unexported fields
}
DeprecatedAnnotation is a wrapper for a value provided via @schema/deprecated annotation
func NewDeprecatedAnnotation ¶
func NewDeprecatedAnnotation(ann template.NodeAnnotation, pos *filepos.Position) (*DeprecatedAnnotation, error)
NewDeprecatedAnnotation validates the value from the AnnotationDeprecated, and returns the value
func (*DeprecatedAnnotation) GetPosition ¶
func (d *DeprecatedAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*DeprecatedAnnotation) NewTypeFromAnn ¶
func (d *DeprecatedAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation. DeprecatedAnnotation has no type information.
type DescriptionAnnotation ¶
type DescriptionAnnotation struct {
// contains filtered or unexported fields
}
DescriptionAnnotation documents the purpose of a node
func NewDescriptionAnnotation ¶
func NewDescriptionAnnotation(ann template.NodeAnnotation, pos *filepos.Position) (*DescriptionAnnotation, error)
NewDescriptionAnnotation validates the value from the AnnotationDescription, and returns the value
func (*DescriptionAnnotation) GetPosition ¶
func (d *DescriptionAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*DescriptionAnnotation) NewTypeFromAnn ¶
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 ¶
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 ¶
func (t DocumentType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (*DocumentType) GetDefinitionPosition ¶
func (t *DocumentType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*DocumentType) GetDescription ¶
func (t *DocumentType) GetDescription() string
GetDescription provides descriptive information
func (*DocumentType) GetExamples ¶
func (t *DocumentType) GetExamples() []Example
GetExamples provides descriptive example information
func (*DocumentType) GetTitle ¶
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 ¶
func (t *DocumentType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*DocumentType) SetDefaultValue ¶
func (t *DocumentType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value of the entire document to `val`
func (*DocumentType) SetDeprecated ¶
func (t *DocumentType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*DocumentType) SetDescription ¶
func (t *DocumentType) SetDescription(desc string)
SetDescription sets the description of the type
func (*DocumentType) SetExamples ¶
func (t *DocumentType) SetExamples(data []Example)
SetExamples sets the description and example of the type
func (*DocumentType) SetTitle ¶
func (t *DocumentType) SetTitle(title string)
SetTitle sets the title of the type
func (*DocumentType) String ¶
func (t *DocumentType) String() string
String produces a user-friendly name of the expected type.
type Example ¶
type Example struct {
// contains filtered or unexported fields
}
Example contains a yaml example and its description
type ExampleAnnotation ¶
type ExampleAnnotation struct {
// contains filtered or unexported fields
}
ExampleAnnotation provides the Examples of a node
func NewExampleAnnotation ¶
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 ¶
func (e *ExampleAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*ExampleAnnotation) NewTypeFromAnn ¶
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 ¶
func (t MapItemType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (MapItemType) GetDefinitionPosition ¶
func (t MapItemType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*MapItemType) GetDescription ¶
func (t *MapItemType) GetDescription() string
GetDescription provides descriptive information
func (*MapItemType) GetExamples ¶
func (t *MapItemType) GetExamples() []Example
GetExamples provides descriptive example information
func (*MapItemType) GetTitle ¶
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 ¶
func (t *MapItemType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*MapItemType) SetDefaultValue ¶
func (t *MapItemType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*MapItemType) SetDeprecated ¶
func (t *MapItemType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*MapItemType) SetDescription ¶
func (t *MapItemType) SetDescription(desc string)
SetDescription sets the description of the type
func (*MapItemType) SetExamples ¶
func (t *MapItemType) SetExamples(exs []Example)
SetExamples sets the description and example of the type
func (*MapItemType) SetTitle ¶
func (t *MapItemType) SetTitle(title string)
SetTitle sets the title of the type
func (MapItemType) String ¶
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 ¶
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 ¶
func (m MapType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (MapType) GetDefinitionPosition ¶
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*MapType) GetDescription ¶
GetDescription provides descriptive information
func (*MapType) GetExamples ¶
GetExamples provides descriptive example information
func (MapType) GetValueType ¶
GetValueType provides the type of the value
func (*MapType) IsDeprecated ¶
IsDeprecated provides deprecated field information
func (*MapType) SetDefaultValue ¶
func (m *MapType) SetDefaultValue(val interface{})
SetDefaultValue is ignored as default values should be set on each MapItemType, individually.
func (*MapType) SetDeprecated ¶
SetDeprecated sets the deprecated field value
func (*MapType) SetDescription ¶
SetDescription sets the description of the type
func (*MapType) SetExamples ¶
SetExamples sets the description and example of the type
type NullType ¶
type NullType struct { ValueType Type Position *filepos.Position // contains filtered or unexported fields }
func (NullType) AssignTypeTo ¶
AssignTypeTo assigns this NullType's wrapped Type to `node`.
func (NullType) CheckType ¶
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 ¶
func (n NullType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (NullType) GetDefinitionPosition ¶
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*NullType) GetDescription ¶
GetDescription provides descriptive information
func (*NullType) GetExamples ¶
GetExamples provides descriptive example information
func (NullType) GetValueType ¶
GetValueType provides the type of the value
func (*NullType) IsDeprecated ¶
IsDeprecated provides deprecated field information
func (*NullType) SetDefaultValue ¶
func (n *NullType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value of the wrapped type to `val`
func (*NullType) SetDeprecated ¶
SetDeprecated sets the deprecated field value
func (*NullType) SetDescription ¶
SetDescription sets the description of the type
func (*NullType) SetExamples ¶
SetExamples sets the description and example of the type
type NullableAnnotation ¶
type NullableAnnotation struct {
// contains filtered or unexported fields
}
func NewNullableAnnotation ¶
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 ¶
func (n *NullableAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*NullableAnnotation) NewTypeFromAnn ¶
func (n *NullableAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation.
type OpenAPIDocument ¶
type OpenAPIDocument struct {
// contains filtered or unexported fields
}
OpenAPIDocument holds the document type used for creating an OpenAPI document
func NewOpenAPIDocument ¶
func NewOpenAPIDocument(docType *DocumentType) *OpenAPIDocument
NewOpenAPIDocument creates an instance of an OpenAPIDocument based on the given DocumentType
func (*OpenAPIDocument) AsDocument ¶
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 ¶
func (s ScalarType) GetDefaultValue() interface{}
GetDefaultValue provides the default value
func (ScalarType) GetDefinitionPosition ¶
func (s ScalarType) GetDefinitionPosition() *filepos.Position
GetDefinitionPosition reports the location in source schema that contains this type definition.
func (*ScalarType) GetDescription ¶
func (s *ScalarType) GetDescription() string
GetDescription provides descriptive information
func (*ScalarType) GetExamples ¶
func (s *ScalarType) GetExamples() []Example
GetExamples provides descriptive example information
func (*ScalarType) GetTitle ¶
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 ¶
func (s *ScalarType) IsDeprecated() (bool, string)
IsDeprecated provides deprecated field information
func (*ScalarType) SetDefaultValue ¶
func (s *ScalarType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ScalarType) SetDeprecated ¶
func (s *ScalarType) SetDeprecated(deprecated bool, notice string)
SetDeprecated sets the deprecated field value
func (*ScalarType) SetDescription ¶
func (s *ScalarType) SetDescription(desc string)
SetDescription sets the description of the type
func (*ScalarType) SetExamples ¶
func (s *ScalarType) SetExamples(exs []Example)
SetExamples sets the description and example of the type
func (*ScalarType) SetTitle ¶
func (s *ScalarType) SetTitle(title string)
SetTitle sets the title of the type
func (ScalarType) String ¶
func (s ScalarType) String() string
String produces a user-friendly name of the expected type.
type TitleAnnotation ¶
type TitleAnnotation struct {
// contains filtered or unexported fields
}
TitleAnnotation provides title of a node
func NewTitleAnnotation ¶
func NewTitleAnnotation(ann template.NodeAnnotation, pos *filepos.Position) (*TitleAnnotation, error)
NewTitleAnnotation validates the value from the AnnotationTitle, and returns the value
func (*TitleAnnotation) GetPosition ¶
func (t *TitleAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*TitleAnnotation) NewTypeFromAnn ¶
func (t *TitleAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation. TitleAnnotation has no type information.
type Type ¶
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 ¶
type TypeAnnotation struct {
// contains filtered or unexported fields
}
func NewTypeAnnotation ¶
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 ¶
func (t *TypeAnnotation) GetPosition() *filepos.Position
GetPosition returns position of the source comment used to create this annotation.
func (*TypeAnnotation) IsAny ¶
func (t *TypeAnnotation) IsAny() bool
func (*TypeAnnotation) NewTypeFromAnn ¶
func (t *TypeAnnotation) NewTypeFromAnn() (Type, error)
NewTypeFromAnn returns type information given by annotation.
type TypeCheck ¶
type TypeCheck struct {
Violations []error
}
TypeCheck is the result of checking a yamlmeta.Node structure against a given Type, recursively.
func CheckNode ¶
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 ¶
Error generates the error message composed of the total set of TypeCheck.Violations.
func (*TypeCheck) HasViolations ¶
HasViolations indicates whether this TypeCheck contains any violations.