Documentation
¶
Index ¶
- Constants
- func NewMismatchedTypeAssertionError(foundType yamlmeta.TypeWithValues, expectedType yamlmeta.Type) error
- func NewSchemaError(summary string, errs ...error) error
- func NewUnexpectedKeyAssertionError(found *yamlmeta.MapItem, definition *filepos.Position, allowedKeys []string) error
- type Annotation
- type AnyType
- func (a AnyType) AssignTypeTo(yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
- func (a AnyType) CheckType(_ yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (a AnyType) GetDefaultValue() interface{}
- func (a AnyType) GetDefinitionPosition() *filepos.Position
- func (a *AnyType) GetDescription() string
- func (a AnyType) GetValueType() yamlmeta.Type
- func (a *AnyType) SetDefaultValue(val interface{})
- func (a *AnyType) SetDescription(desc string)
- func (a AnyType) String() string
- type ArrayItemType
- func (a *ArrayItemType) AssignTypeTo(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
- func (a *ArrayItemType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (a ArrayItemType) GetDefaultValue() interface{}
- func (a ArrayItemType) GetDefinitionPosition() *filepos.Position
- func (a *ArrayItemType) GetDescription() string
- func (a ArrayItemType) GetValueType() yamlmeta.Type
- func (a *ArrayItemType) SetDefaultValue(val interface{})
- func (a *ArrayItemType) SetDescription(desc string)
- func (a ArrayItemType) String() string
- type ArrayType
- func (a *ArrayType) AssignTypeTo(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
- func (a *ArrayType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (a ArrayType) GetDefaultValue() interface{}
- func (a ArrayType) GetDefinitionPosition() *filepos.Position
- func (a *ArrayType) GetDescription() string
- func (a ArrayType) GetValueType() yamlmeta.Type
- func (a *ArrayType) SetDefaultValue(val interface{})
- func (a *ArrayType) SetDescription(desc string)
- func (a ArrayType) String() string
- type DefaultAnnotation
- type DescriptionAnnotation
- type DocumentSchema
- type DocumentSchemaEnvelope
- func (e *DocumentSchemaEnvelope) Desc() string
- func (e *DocumentSchemaEnvelope) IntendedForAnotherLibrary() bool
- func (e *DocumentSchemaEnvelope) IsUsed() bool
- func (e *DocumentSchemaEnvelope) Source() *yamlmeta.Document
- func (e *DocumentSchemaEnvelope) UsedInLibrary(expectedRefPiece ref.LibraryRef) (*DocumentSchemaEnvelope, bool)
- type DocumentType
- func (t *DocumentType) AssignTypeTo(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
- func (t *DocumentType) CheckType(_ yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (t DocumentType) GetDefaultValue() interface{}
- func (t *DocumentType) GetDefinitionPosition() *filepos.Position
- func (t *DocumentType) GetDescription() string
- func (t *DocumentType) GetValueType() yamlmeta.Type
- func (t *DocumentType) SetDefaultValue(val interface{})
- func (t *DocumentType) SetDescription(desc string)
- func (t *DocumentType) String() string
- type ExtractLibRefs
- type MapItemType
- func (t *MapItemType) AssignTypeTo(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
- func (t *MapItemType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (t MapItemType) GetDefaultValue() interface{}
- func (t MapItemType) GetDefinitionPosition() *filepos.Position
- func (t *MapItemType) GetDescription() string
- func (t MapItemType) GetValueType() yamlmeta.Type
- func (t *MapItemType) SetDefaultValue(val interface{})
- func (t *MapItemType) SetDescription(desc string)
- func (t MapItemType) String() string
- type MapType
- func (m *MapType) AllowedKeys() []string
- func (m *MapType) AllowsKey(key interface{}) bool
- func (m *MapType) AssignTypeTo(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
- func (m *MapType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (m MapType) GetDefaultValue() interface{}
- func (m MapType) GetDefinitionPosition() *filepos.Position
- func (m *MapType) GetDescription() string
- func (m MapType) GetValueType() yamlmeta.Type
- func (m *MapType) SetDefaultValue(val interface{})
- func (m *MapType) SetDescription(desc string)
- func (m MapType) String() string
- type NullType
- func (n NullType) AssignTypeTo(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
- func (n NullType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (n NullType) GetDefaultValue() interface{}
- func (n NullType) GetDefinitionPosition() *filepos.Position
- func (n *NullType) GetDescription() string
- func (n NullType) GetValueType() yamlmeta.Type
- func (n *NullType) SetDefaultValue(val interface{})
- func (n *NullType) SetDescription(desc string)
- func (n NullType) String() string
- type NullableAnnotation
- type OpenAPIDocument
- type ScalarType
- func (s *ScalarType) AssignTypeTo(typeable yamlmeta.Typeable) yamlmeta.TypeCheck
- func (s *ScalarType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
- func (s ScalarType) GetDefaultValue() interface{}
- func (s ScalarType) GetDefinitionPosition() *filepos.Position
- func (s *ScalarType) GetDescription() string
- func (s ScalarType) GetValueType() yamlmeta.Type
- func (s *ScalarType) SetDefaultValue(val interface{})
- func (s *ScalarType) SetDescription(desc string)
- func (s ScalarType) String() string
- type TypeAnnotation
Constants ¶
const ( AnnotationNullable template.AnnotationName = "schema/nullable" AnnotationType template.AnnotationName = "schema/type" AnnotationDefault template.AnnotationName = "schema/default" AnnotationDescription template.AnnotationName = "schema/desc" TypeAnnotationKwargAny string = "any" )
Variables ¶
This section is empty.
Functions ¶
func NewMismatchedTypeAssertionError ¶ added in v0.35.0
func NewMismatchedTypeAssertionError(foundType yamlmeta.TypeWithValues, expectedType yamlmeta.Type) error
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
func (AnyType) CheckType ¶ added in v0.34.0
func (a AnyType) CheckType(_ yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
func (AnyType) GetDefaultValue ¶ added in v0.35.0
func (a AnyType) GetDefaultValue() interface{}
func (AnyType) GetDefinitionPosition ¶ added in v0.35.0
func (*AnyType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (AnyType) GetValueType ¶ added in v0.34.0
func (*AnyType) SetDefaultValue ¶ added in v0.38.0
func (a *AnyType) SetDefaultValue(val interface{})
SetDefaultValue does nothing
func (*AnyType) SetDescription ¶ added in v0.38.0
SetDescription sets the description of the type
type ArrayItemType ¶
type ArrayItemType struct {
ValueType yamlmeta.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(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
func (*ArrayItemType) CheckType ¶
func (a *ArrayItemType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
func (ArrayItemType) GetDefaultValue ¶ added in v0.35.0
func (a ArrayItemType) GetDefaultValue() interface{}
func (ArrayItemType) GetDefinitionPosition ¶ added in v0.35.0
func (a ArrayItemType) GetDefinitionPosition() *filepos.Position
func (*ArrayItemType) GetDescription ¶ added in v0.38.0
func (a *ArrayItemType) GetDescription() string
GetDescription provides descriptive information
func (ArrayItemType) GetValueType ¶
func (a ArrayItemType) GetValueType() yamlmeta.Type
func (*ArrayItemType) SetDefaultValue ¶ added in v0.38.0
func (a *ArrayItemType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ArrayItemType) SetDescription ¶ added in v0.38.0
func (a *ArrayItemType) SetDescription(desc string)
SetDescription sets the description of the type
func (ArrayItemType) String ¶ added in v0.32.0
func (a ArrayItemType) String() string
type ArrayType ¶
type ArrayType struct {
ItemsType yamlmeta.Type
Position *filepos.Position
// contains filtered or unexported fields
}
func (*ArrayType) AssignTypeTo ¶
func (*ArrayType) CheckType ¶
func (a *ArrayType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
func (ArrayType) GetDefaultValue ¶ added in v0.35.0
func (a ArrayType) GetDefaultValue() interface{}
func (ArrayType) GetDefinitionPosition ¶ added in v0.35.0
func (*ArrayType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (ArrayType) GetValueType ¶
func (*ArrayType) SetDefaultValue ¶ added in v0.38.0
func (a *ArrayType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ArrayType) SetDescription ¶ added in v0.38.0
SetDescription sets the description 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 yamlmeta.Type, pos *filepos.Position) (*DefaultAnnotation, error)
NewDefaultAnnotation checks the argument provided via @schema/default annotation, and returns wrapper for that value.
func (*DefaultAnnotation) NewTypeFromAnn ¶ added in v0.38.0
func (n *DefaultAnnotation) NewTypeFromAnn() (yamlmeta.Type, error)
NewTypeFromAnn returns type information given by annotation.
func (*DefaultAnnotation) Val ¶ added in v0.38.0
func (n *DefaultAnnotation) Val() interface{}
Val returns default value specified in annotation.
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) NewTypeFromAnn ¶ added in v0.38.0
func (n *DescriptionAnnotation) NewTypeFromAnn() (yamlmeta.Type, error)
NewTypeFromAnn returns type information given by annotation. DescriptionAnnotation has no type information.
type DocumentSchema ¶
type DocumentSchema struct {
Source *yamlmeta.Document
DocType *DocumentType
// contains filtered or unexported fields
}
func NewDocumentSchema ¶
func NewDocumentSchema(doc *yamlmeta.Document) (*DocumentSchema, error)
func NewNullSchema ¶ added in v0.35.0
func NewNullSchema() *DocumentSchema
NewNullSchema provides the "Null Object" value of Schema. This is used in the case where no schema was provided.
func (*DocumentSchema) AssignType ¶
func (s *DocumentSchema) AssignType(typeable yamlmeta.Typeable) yamlmeta.TypeCheck
func (*DocumentSchema) DefaultDataValues ¶ added in v0.32.0
func (s *DocumentSchema) DefaultDataValues() *yamlmeta.Document
func (*DocumentSchema) GetDocumentType ¶ added in v0.38.0
func (s *DocumentSchema) GetDocumentType() *DocumentType
GetDocumentType returns a reference to the DocumentType that is the root of this Schema.
type DocumentSchemaEnvelope ¶ added in v0.34.0
type DocumentSchemaEnvelope struct {
Doc *DocumentSchema
// contains filtered or unexported fields
}
func NewDocumentSchemaEnvelope ¶ added in v0.34.0
func NewDocumentSchemaEnvelope(doc *yamlmeta.Document) (*DocumentSchemaEnvelope, error)
func (*DocumentSchemaEnvelope) Desc ¶ added in v0.34.0
func (e *DocumentSchemaEnvelope) Desc() string
func (*DocumentSchemaEnvelope) IntendedForAnotherLibrary ¶ added in v0.34.0
func (e *DocumentSchemaEnvelope) IntendedForAnotherLibrary() bool
func (*DocumentSchemaEnvelope) IsUsed ¶ added in v0.34.0
func (e *DocumentSchemaEnvelope) IsUsed() bool
func (*DocumentSchemaEnvelope) Source ¶ added in v0.34.0
func (e *DocumentSchemaEnvelope) Source() *yamlmeta.Document
func (*DocumentSchemaEnvelope) UsedInLibrary ¶ added in v0.34.0
func (e *DocumentSchemaEnvelope) UsedInLibrary(expectedRefPiece ref.LibraryRef) (*DocumentSchemaEnvelope, bool)
type DocumentType ¶
type DocumentType struct {
Source *yamlmeta.Document
ValueType yamlmeta.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)
func (*DocumentType) AssignTypeTo ¶
func (t *DocumentType) AssignTypeTo(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
func (*DocumentType) CheckType ¶
func (t *DocumentType) CheckType(_ yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
func (DocumentType) GetDefaultValue ¶ added in v0.35.0
func (t DocumentType) GetDefaultValue() interface{}
func (*DocumentType) GetDefinitionPosition ¶ added in v0.35.0
func (t *DocumentType) GetDefinitionPosition() *filepos.Position
func (*DocumentType) GetDescription ¶ added in v0.38.0
func (t *DocumentType) GetDescription() string
GetDescription provides descriptive information
func (*DocumentType) GetValueType ¶
func (t *DocumentType) GetValueType() yamlmeta.Type
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) SetDescription ¶ added in v0.38.0
func (t *DocumentType) SetDescription(desc string)
SetDescription sets the description of the type
func (*DocumentType) String ¶ added in v0.32.0
func (t *DocumentType) String() string
type ExtractLibRefs ¶ added in v0.34.0
type ExtractLibRefs interface {
FromAnnotation(template.NodeAnnotations) ([]ref.LibraryRef, error)
}
type MapItemType ¶
type MapItemType struct {
Key interface{} // usually a string
ValueType yamlmeta.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(typeable yamlmeta.Typeable) (chk yamlmeta.TypeCheck)
func (*MapItemType) CheckType ¶
func (t *MapItemType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
func (MapItemType) GetDefaultValue ¶ added in v0.35.0
func (t MapItemType) GetDefaultValue() interface{}
func (MapItemType) GetDefinitionPosition ¶ added in v0.35.0
func (t MapItemType) GetDefinitionPosition() *filepos.Position
func (*MapItemType) GetDescription ¶ added in v0.38.0
func (t *MapItemType) GetDescription() string
GetDescription provides descriptive information
func (MapItemType) GetValueType ¶
func (t MapItemType) GetValueType() yamlmeta.Type
func (*MapItemType) SetDefaultValue ¶ added in v0.38.0
func (t *MapItemType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*MapItemType) SetDescription ¶ added in v0.38.0
func (t *MapItemType) SetDescription(desc string)
SetDescription sets the description of the type
func (MapItemType) String ¶ added in v0.32.0
func (t MapItemType) String() string
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) AssignTypeTo ¶
func (*MapType) CheckType ¶
func (m *MapType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
func (MapType) GetDefaultValue ¶ added in v0.35.0
func (m MapType) GetDefaultValue() interface{}
func (MapType) GetDefinitionPosition ¶ added in v0.35.0
func (*MapType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (MapType) GetValueType ¶
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) SetDescription ¶ added in v0.38.0
SetDescription sets the description of the type
type NullType ¶ added in v0.34.0
type NullType struct {
ValueType yamlmeta.Type
Position *filepos.Position
// contains filtered or unexported fields
}
func (NullType) AssignTypeTo ¶ added in v0.34.0
func (NullType) CheckType ¶ added in v0.34.0
func (n NullType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
func (NullType) GetDefaultValue ¶ added in v0.35.0
func (n NullType) GetDefaultValue() interface{}
func (NullType) GetDefinitionPosition ¶ added in v0.35.0
func (*NullType) GetDescription ¶ added in v0.38.0
GetDescription provides descriptive information
func (NullType) GetValueType ¶ added in v0.34.0
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) SetDescription ¶ added in v0.38.0
SetDescription sets the description 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) NewTypeFromAnn ¶ added in v0.34.0
func (n *NullableAnnotation) NewTypeFromAnn() (yamlmeta.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(typeable yamlmeta.Typeable) yamlmeta.TypeCheck
AssignTypeTo validates that the type is compatible and assigns it to the type
func (*ScalarType) CheckType ¶
func (s *ScalarType) CheckType(node yamlmeta.TypeWithValues) (chk yamlmeta.TypeCheck)
CheckType validates the type of the node and the type of the value
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 provides the file position
func (*ScalarType) GetDescription ¶ added in v0.38.0
func (s *ScalarType) GetDescription() string
GetDescription provides descriptive information
func (ScalarType) GetValueType ¶
func (s ScalarType) GetValueType() yamlmeta.Type
GetValueType provides the type of the value
func (*ScalarType) SetDefaultValue ¶ added in v0.38.0
func (s *ScalarType) SetDefaultValue(val interface{})
SetDefaultValue sets the default value to `val`
func (*ScalarType) SetDescription ¶ added in v0.38.0
func (s *ScalarType) SetDescription(desc string)
SetDescription sets the description of the type
func (ScalarType) String ¶ added in v0.32.0
func (s ScalarType) String() string
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) IsAny ¶ added in v0.34.0
func (t *TypeAnnotation) IsAny() bool
func (*TypeAnnotation) NewTypeFromAnn ¶ added in v0.34.0
func (t *TypeAnnotation) NewTypeFromAnn() (yamlmeta.Type, error)
NewTypeFromAnn returns type information given by annotation.