Versions in this module Expand all Collapse all v0 v0.0.1 Oct 16, 2022 Changes in this version + const Epsilon + const FormatBinary + const FormatByte + const FormatConflowID + const FormatDate + const FormatDateTime + const FormatDefault + const FormatDurationGo + const FormatDurationRFC3339 + const FormatEmail + const FormatHostname + const FormatIDNEmail + const FormatIDNHostname + const FormatIP + const FormatIPCIDR + const FormatIPv4 + const FormatIPv4CIDR + const FormatIPv6 + const FormatIPv6CIDR + const FormatIRI + const FormatIRIReference + const FormatRegex + const FormatTime + const FormatURI + const FormatURIReference + const FormatUUID + const NameRegExpPattern + var ErrMetadataReadOnly = errors.New("metadata is read-only") + var FieldNameRegexp = regexp.MustCompile("^[_a-zA-Z][_a-zA-Z0-9]*$") + var NameRegExp = regexp.MustCompile("^" + NameRegExpPattern + "$") + func NumberEquals(a, b float64) bool + func NumberGreaterThan(v1, v2 float64) bool + func NumberGreaterThanOrEqualsTo(v1, v2 float64) bool + func NumberLessThan(v1, v2 float64) bool + func NumberLessThanOrEqualsTo(v1, v2 float64) bool + func NumberMultipleOf(v1, v2 float64) bool + func Pointer(v V) *V + func Register(s Schema) + func RegisterFormat(name string, format Format) + func RegisterResolver(uri string, res Resolver) + func UnregisterFormat(name string) + func UpdateMetadata(s Schema, f func(meta MetadataAccessor) error) error + func ValueOf(v *V) (r V) + type AllOf struct + Schemas []Schema + func (a *AllOf) AssignValue(imports map[string]string, valueName, resultName string) string + func (a *AllOf) CompareValues(v1, v2 interface{}) int + func (a *AllOf) Copy() Schema + func (a *AllOf) DefaultValue() interface{} + func (a *AllOf) GoString(imports map[string]string) string + func (a *AllOf) GoType(imports map[string]string) string + func (a *AllOf) StringValue(value interface{}) string + func (a *AllOf) Type() Type + func (a *AllOf) TypeString() string + func (a *AllOf) UnmarshalJSON(j []byte) error + func (a *AllOf) ValidateSchema(s Schema, compare bool) error + func (a *AllOf) ValidateValue(value interface{}) (interface{}, error) + type Array struct + Const []interface{} + Default []interface{} + Enum [][]interface{} + Items Schema + MaxItems *int64 + MinItems int64 + UniqueItems bool + func (a *Array) AssignValue(imports map[string]string, valueName, resultName string) string + func (a *Array) CompareValues(v1, v2 interface{}) int + func (a *Array) Copy() Schema + func (a *Array) DefaultValue() interface{} + func (a *Array) GetItems() Schema + func (a *Array) GoString(imports map[string]string) string + func (a *Array) GoType(imports map[string]string) string + func (a *Array) MarshalJSON() ([]byte, error) + func (a *Array) StringValue(value interface{}) string + func (a *Array) Type() Type + func (a *Array) TypeString() string + func (a *Array) UnmarshalJSON(j []byte) error + func (a *Array) ValidateSchema(s Schema, compare bool) error + func (a *Array) ValidateValue(value interface{}) (interface{}, error) + type Boolean struct + Const *bool + Default *bool + Enum []bool + Nullable bool + func (b *Boolean) AssignValue(imports map[string]string, valueName, resultName string) string + func (b *Boolean) CompareValues(v1, v2 interface{}) int + func (b *Boolean) Copy() Schema + func (b *Boolean) DefaultValue() interface{} + func (b *Boolean) GetNullable() bool + func (b *Boolean) GoString(imports map[string]string) string + func (b *Boolean) GoType(_ map[string]string) string + func (b *Boolean) MarshalJSON() ([]byte, error) + func (b *Boolean) SetNullable(nullable bool) + func (b *Boolean) StringValue(value interface{}) string + func (b *Boolean) Type() Type + func (b *Boolean) TypeString() string + func (b *Boolean) UnmarshalJSON(input []byte) error + func (b *Boolean) ValidateSchema(b2 Schema, _ bool) error + func (b *Boolean) ValidateValue(value interface{}) (interface{}, error) + type ByteStream struct + func (b *ByteStream) AssignValue(imports map[string]string, valueName, resultName string) string + func (b *ByteStream) CompareValues(v1, v2 interface{}) int + func (b *ByteStream) Copy() Schema + func (b *ByteStream) DefaultValue() interface{} + func (b *ByteStream) GoString(imports map[string]string) string + func (b *ByteStream) GoType(imports map[string]string) string + func (b *ByteStream) MarshalJSON() ([]byte, error) + func (b *ByteStream) StringValue(value interface{}) string + func (b *ByteStream) Type() Type + func (b *ByteStream) TypeString() string + func (b *ByteStream) ValidateSchema(s2 Schema, compare bool) error + func (b *ByteStream) ValidateValue(value interface{}) (interface{}, error) + type Directive interface + ApplyToSchema func(Schema) error + type FieldError struct + Err error + Field string + func NewFieldError(field string, err error) FieldError + func NewFieldErrorf(field, format string, a ...interface{}) FieldError + func (f FieldError) Error() string + type Format interface + StringValue func(input interface{}) (string, bool) + Type func() (reflect.Type, bool) + ValidateValue func(input string) (interface{}, error) + func GetFormat(name string) (Format, bool) + func GetFormatForType(path string) (string, Format, bool) + type Function struct + AdditionalParameters *NamedSchema + Parameters Parameters + Result Schema + ResultTypeFrom string + func (f *Function) AssignValue(_ map[string]string, _, _ string) string + func (f *Function) CompareValues(_, _ interface{}) int + func (f *Function) Copy() Schema + func (f *Function) DefaultValue() interface{} + func (f *Function) GetAdditionalParameters() *NamedSchema + func (f *Function) GetParameters() Parameters + func (f *Function) GetResult() Schema + func (f *Function) GetResultTypeFrom() string + func (f *Function) GoString(imports map[string]string) string + func (f *Function) GoType(imports map[string]string) string + func (f *Function) MarshalJSON() ([]byte, error) + func (f *Function) StringValue(interface{}) string + func (f *Function) Type() Type + func (f *Function) TypeString() string + func (f *Function) UnmarshalJSON(j []byte) error + func (f *Function) ValidateSchema(s Schema, compare bool) error + func (f *Function) ValidateValue(value interface{}) (interface{}, error) + type Integer struct + Const *int64 + Default *int64 + Enum []int64 + ExclusiveMaximum *int64 + ExclusiveMinimum *int64 + Format string + Maximum *int64 + Minimum *int64 + MultipleOf *int64 + Nullable bool + func (i *Integer) AssignValue(imports map[string]string, valueName, resultName string) string + func (i *Integer) CompareValues(v1, v2 interface{}) int + func (i *Integer) Copy() Schema + func (i *Integer) DefaultValue() interface{} + func (i *Integer) GetNullable() bool + func (i *Integer) GoString(imports map[string]string) string + func (i *Integer) GoType(_ map[string]string) string + func (i *Integer) MarshalJSON() ([]byte, error) + func (i *Integer) SetNullable(nullable bool) + func (i *Integer) StringValue(value interface{}) string + func (i *Integer) Type() Type + func (i *Integer) TypeString() string + func (i *Integer) UnmarshalJSON(input []byte) error + func (i *Integer) ValidateSchema(i2 Schema, compare bool) error + func (i *Integer) ValidateValue(value interface{}) (interface{}, error) + type Map struct + AdditionalProperties Schema + Const map[string]interface{} + Default map[string]interface{} + Enum []map[string]interface{} + MaxProperties *int64 + MinProperties int64 + func (m *Map) AssignValue(imports map[string]string, valueName, resultName string) string + func (m *Map) CompareValues(v1, v2 interface{}) int + func (m *Map) Copy() Schema + func (m *Map) DefaultValue() interface{} + func (m *Map) GetAdditionalProperties() Schema + func (m *Map) GoString(imports map[string]string) string + func (m *Map) GoType(imports map[string]string) string + func (m *Map) MarshalJSON() ([]byte, error) + func (m *Map) StringValue(value interface{}) string + func (m *Map) Type() Type + func (m *Map) TypeString() string + func (m *Map) UnmarshalJSON(j []byte) error + func (m *Map) ValidateSchema(s Schema, compare bool) error + func (m *Map) ValidateValue(value interface{}) (interface{}, error) + type Metadata struct + Annotations map[string]string + Deprecated bool + Description string + Examples []interface{} + ID string + ReadOnly bool + Title string + WriteOnly bool + func (m *Metadata) GetAnnotation(name string) string + func (m *Metadata) GetDeprecated() bool + func (m *Metadata) GetDescription() string + func (m *Metadata) GetReadOnly() bool + func (m *Metadata) GetTitle() string + func (m *Metadata) GetWriteOnly() bool + func (m *Metadata) GoString(imports map[string]string) string + func (m *Metadata) Merge(m2 Metadata) + func (m *Metadata) SetAnnotation(name, value string) + func (m *Metadata) SetDeprecated(deprecated bool) + func (m *Metadata) SetDescription(description string) + func (m *Metadata) SetExamples(examples []interface{}) + func (m *Metadata) SetID(id string) + func (m *Metadata) SetReadOnly(readOnly bool) + func (m *Metadata) SetTitle(title string) + func (m *Metadata) SetWriteOnly(writeOnly bool) + func (m Metadata) GetExamples() []interface{} + func (m Metadata) GetID() string + type MetadataAccessor interface + Merge func(Metadata) + SetAnnotation func(string, string) + SetDeprecated func(bool) + SetDescription func(string) + SetExamples func([]interface{}) + SetID func(string) + SetReadOnly func(bool) + SetTitle func(string) + SetWriteOnly func(bool) + type NamedSchema struct + Name string + func (n NamedSchema) GoString(imports map[string]string) string + type NonEmptyString = string + type Null struct + func (n *Null) AssignValue(_ map[string]string, _, resultName string) string + func (n *Null) CompareValues(v1, v2 interface{}) int + func (n *Null) Copy() Schema + func (n *Null) DefaultValue() interface{} + func (n *Null) GoString(imports map[string]string) string + func (n *Null) GoType(_ map[string]string) string + func (n *Null) MarshalJSON() ([]byte, error) + func (n *Null) StringValue(interface{}) string + func (n *Null) Type() Type + func (n *Null) TypeString() string + func (n *Null) ValidateSchema(n2 Schema, _ bool) error + func (n *Null) ValidateValue(v interface{}) (interface{}, error) + type Nullable interface + GetNullable func() bool + SetNullable func(bool) + type Number struct + Const *float64 + Default *float64 + Enum []float64 + ExclusiveMaximum *float64 + ExclusiveMinimum *float64 + Maximum *float64 + Minimum *float64 + MultipleOf *float64 + Nullable bool + func (n *Number) AssignValue(imports map[string]string, valueName, resultName string) string + func (n *Number) CompareValues(v1, v2 interface{}) int + func (n *Number) Copy() Schema + func (n *Number) DefaultValue() interface{} + func (n *Number) GetNullable() bool + func (n *Number) GoString(imports map[string]string) string + func (n *Number) GoType(_ map[string]string) string + func (n *Number) MarshalJSON() ([]byte, error) + func (n *Number) SetNullable(nullable bool) + func (n *Number) StringValue(value interface{}) string + func (n *Number) Type() Type + func (n *Number) TypeString() string + func (n *Number) UnmarshalJSON(input []byte) error + func (n *Number) ValidateSchema(n2 Schema, _ bool) error + func (n *Number) ValidateValue(value interface{}) (interface{}, error) + type Object struct + Const map[string]interface{} + Default map[string]interface{} + DependentRequired map[string][]string + Enum []map[string]interface{} + FieldNames map[string]string + JSONPropertyNames map[string]string + MaxProperties *int64 + MinProperties int64 + ParameterNames map[string]string + Properties map[string]Schema + Required []string + func (o *Object) AssignValue(_ map[string]string, _, _ string) string + func (o *Object) CompareValues(v1, v2 interface{}) int + func (o *Object) Copy() Schema + func (o *Object) DefaultValue() interface{} + func (o *Object) FieldName(parameterName string) string + func (o *Object) GoString(imports map[string]string) string + func (o *Object) GoType(imports map[string]string) string + func (o *Object) IsPropertyRequired(jsonPropertyName string) bool + func (o *Object) JSONPropertyName(parameterName string) string + func (o *Object) MarshalJSON() ([]byte, error) + func (o *Object) ParameterName(jsonPropertyName string) string + func (o *Object) PropertyByParameterName(parameterName string) (Schema, bool) + func (o *Object) StringValue(value interface{}) string + func (o *Object) Type() Type + func (o *Object) TypeString() string + func (o *Object) UnmarshalJSON(j []byte) error + func (o *Object) ValidateSchema(s Schema, compare bool) error + func (o *Object) ValidateValue(value interface{}) (interface{}, error) + type Parameters []NamedSchema + func (p *Parameters) UnmarshalJSON(j []byte) error + func (p Parameters) GoString(imports map[string]string) string + func (p Parameters) MarshalJSON() ([]byte, error) + type Reference struct + Nullable bool + Ref string + func (r *Reference) AssignValue(imports map[string]string, valueName, resultName string) string + func (r *Reference) CompareValues(a, b interface{}) int + func (r *Reference) Copy() Schema + func (r *Reference) DefaultValue() interface{} + func (r *Reference) GetNullable() bool + func (r *Reference) GoString(imports map[string]string) string + func (r *Reference) GoType(imports map[string]string) string + func (r *Reference) SetNullable(nullable bool) + func (r *Reference) StringValue(value interface{}) string + func (r *Reference) Type() Type + func (r *Reference) TypeString() string + func (r *Reference) ValidateSchema(s Schema, compare bool) error + func (r *Reference) ValidateValue(value interface{}) (interface{}, error) + type Registry struct + func (r *Registry) GetSchema(uri string) (Schema, error) + func (r *Registry) RegisterResolver(uri string, res Resolver) + func (r *Registry) RegisterSchema(s Schema) + type Resolver interface + ResolveSchema func(uri string) (Schema, error) + type ResolverFunc func(uri string) (Schema, error) + func (f ResolverFunc) ResolveSchema(uri string) (Schema, error) + type Schema interface + AssignValue func(imports map[string]string, valueName, resultName string) string + CompareValues func(a, b interface{}) int + Copy func() Schema + DefaultValue func() interface{} + GetAnnotation func(string) string + GetDeprecated func() bool + GetDescription func() string + GetExamples func() []interface{} + GetID func() string + GetReadOnly func() bool + GetTitle func() string + GetWriteOnly func() bool + GoString func(imports map[string]string) string + GoType func(imports map[string]string) string + StringValue func(interface{}) string + Type func() Type + TypeString func() string + ValidateSchema func(s Schema, compare bool) error + ValidateValue func(interface{}) (interface{}, error) + func BooleanValue() Schema + func ByteStreamValue() Schema + func False() Schema + func Get(uri string) (Schema, error) + func GetCommonSchema(s1, s2 Schema) (Schema, error) + func GetSchemaForValue(value interface{}) (Schema, error) + func GetSchemaForValues(cnt int, s func(i int) (Schema, error)) (Schema, error) + func IntegerValue() Schema + func NullValue() Schema + func NumberValue() Schema + func ResolveFromFile(uri string) (Schema, error) + func StringValue() Schema + func UnmarshalJSON(b []byte) (Schema, error) + func UntypedValue() Schema + type SchemaUnmarshaler struct + Schema Schema + func (s *SchemaUnmarshaler) UnmarshalJSON(j []byte) error + type String struct + Const *string + Default *string + Enum []string + Format string + MaxLength *int64 + MinLength int64 + Nullable bool + Pattern *regexp.Regexp + func (s *String) AssignValue(imports map[string]string, valueName, resultName string) string + func (s *String) CompareValues(v1, v2 interface{}) int + func (s *String) Copy() Schema + func (s *String) DefaultValue() interface{} + func (s *String) GetNullable() bool + func (s *String) GoString(imports map[string]string) string + func (s *String) GoType(imports map[string]string) string + func (s *String) MarshalJSON() ([]byte, error) + func (s *String) SetNullable(nullable bool) + func (s *String) StringValue(value interface{}) string + func (s *String) Type() Type + func (s *String) TypeString() string + func (s *String) UnmarshalJSON(input []byte) error + func (s *String) ValidateSchema(s2 Schema, _ bool) error + func (s *String) ValidateValue(value interface{}) (interface{}, error) + type Type string + const TypeArray + const TypeBoolean + const TypeByteStream + const TypeFalse + const TypeFunction + const TypeInteger + const TypeMap + const TypeNull + const TypeNumber + const TypeObject + const TypeReference + const TypeString + const TypeUntyped + type UniqueNonEmptyStringList = []NonEmptyString + type Untyped struct + Types []string + func (u *Untyped) AssignValue(_ map[string]string, valueName, resultName string) string + func (u *Untyped) CompareValues(v1, v2 interface{}) int + func (u *Untyped) Copy() Schema + func (u *Untyped) DefaultValue() interface{} + func (u *Untyped) GoString(imports map[string]string) string + func (u *Untyped) GoType(_ map[string]string) string + func (u *Untyped) StringValue(value interface{}) string + func (u *Untyped) Type() Type + func (u *Untyped) TypeString() string + func (u *Untyped) ValidateSchema(s Schema, compare bool) error + func (u *Untyped) ValidateValue(v interface{}) (interface{}, error) + type ValidationError struct + Errors []error + func (v *ValidationError) AddError(field string, err error) + func (v *ValidationError) AddErrorf(field, format string, a ...interface{}) + func (v ValidationError) ErrOrNil() error + func (v ValidationError) Error() string