Update a few dependencies

github.com/go-openapi/*
github.com/asaskevich/govalidator
This commit is contained in:
Mikhail Mazurskiy
2018-10-18 23:33:10 +11:00
parent b8731a76f0
commit 8763223ab9
191 changed files with 18648 additions and 1800 deletions

View File

@@ -22,6 +22,7 @@ import (
"github.com/go-openapi/swag"
)
// SimpleSchema describe swagger simple schemas for parameters and headers
type SimpleSchema struct {
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
@@ -31,6 +32,7 @@ type SimpleSchema struct {
Example interface{} `json:"example,omitempty"`
}
// TypeName return the type (or format) of a simple schema
func (s *SimpleSchema) TypeName() string {
if s.Format != "" {
return s.Format
@@ -38,6 +40,7 @@ func (s *SimpleSchema) TypeName() string {
return s.Type
}
// ItemsTypeName yields the type of items in a simple schema array
func (s *SimpleSchema) ItemsTypeName() string {
if s.Items == nil {
return ""
@@ -45,6 +48,7 @@ func (s *SimpleSchema) ItemsTypeName() string {
return s.Items.TypeName()
}
// CommonValidations describe common JSON-schema validations
type CommonValidations struct {
Maximum *float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
@@ -212,18 +216,18 @@ func (i Items) MarshalJSON() ([]byte, error) {
}
// JSONLookup look up a value by the json property name
func (p Items) JSONLookup(token string) (interface{}, error) {
func (i Items) JSONLookup(token string) (interface{}, error) {
if token == "$ref" {
return &p.Ref, nil
return &i.Ref, nil
}
r, _, err := jsonpointer.GetForToken(p.CommonValidations, token)
r, _, err := jsonpointer.GetForToken(i.CommonValidations, token)
if err != nil && !strings.HasPrefix(err.Error(), "object has no field") {
return nil, err
}
if r != nil {
return r, nil
}
r, _, err = jsonpointer.GetForToken(p.SimpleSchema, token)
r, _, err = jsonpointer.GetForToken(i.SimpleSchema, token)
return r, err
}