diff options
Diffstat (limited to 'vendor/github.com/go-swagger/go-swagger/codescan/schema.go')
-rw-r--r-- | vendor/github.com/go-swagger/go-swagger/codescan/schema.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/vendor/github.com/go-swagger/go-swagger/codescan/schema.go b/vendor/github.com/go-swagger/go-swagger/codescan/schema.go index 8c6723040..dce74fc30 100644 --- a/vendor/github.com/go-swagger/go-swagger/codescan/schema.go +++ b/vendor/github.com/go-swagger/go-swagger/codescan/schema.go @@ -2,6 +2,7 @@ package codescan import ( "encoding/json" + "errors" "fmt" "go/ast" "go/importer" @@ -15,7 +16,6 @@ import ( "golang.org/x/tools/go/ast/astutil" "github.com/go-openapi/spec" - "github.com/pkg/errors" ) func addExtension(ve *spec.VendorExtensible, key string, value interface{}) { @@ -92,6 +92,7 @@ func (sv schemaValidations) SetMaximum(val float64, exclusive bool) { sv.current.Maximum = &val sv.current.ExclusiveMaximum = exclusive } + func (sv schemaValidations) SetMinimum(val float64, exclusive bool) { sv.current.Minimum = &val sv.current.ExclusiveMinimum = exclusive @@ -358,9 +359,12 @@ func (s *schemaBuilder) buildFromType(tpe types.Type, tgt swaggerTypable) error return nil } + if s.decl.Spec.Assign.IsValid() { + return s.buildFromType(titpe.Underlying(), tgt) + } + switch utitpe := tpe.Underlying().(type) { case *types.Struct: - if decl, ok := s.ctx.FindModel(tio.Pkg().Path(), tio.Name()); ok { if decl.Type.Obj().Pkg().Path() == "time" && decl.Type.Obj().Name() == "Time" { tgt.Typed("string", "date-time") @@ -892,7 +896,7 @@ func (s *schemaBuilder) buildAllOf(tpe types.Type, schema *spec.Schema) error { } return s.buildFromStruct(decl, utpe, schema, make(map[string]string)) } - return errors.Errorf("can't find source file for struct: %s", ftpe.String()) + return fmt.Errorf("can't find source file for struct: %s", ftpe.String()) case *types.Interface: decl, found := s.ctx.FindModel(ftpe.Obj().Pkg().Path(), ftpe.Obj().Name()) if found { @@ -905,7 +909,7 @@ func (s *schemaBuilder) buildAllOf(tpe types.Type, schema *spec.Schema) error { } return s.buildFromInterface(decl, utpe, schema, make(map[string]string)) } - return errors.Errorf("can't find source file for interface: %s", ftpe.String()) + return fmt.Errorf("can't find source file for interface: %s", ftpe.String()) default: log.Printf("WARNING: can't figure out object type for allOf named type (%T): %v", ftpe, ftpe.Underlying()) return fmt.Errorf("unable to locate source file for allOf %s", utpe.String()) @@ -929,13 +933,13 @@ func (s *schemaBuilder) buildEmbedded(tpe types.Type, schema *spec.Schema, seen if found { return s.buildFromStruct(decl, utpe, schema, seen) } - return errors.Errorf("can't find source file for struct: %s", ftpe.String()) + return fmt.Errorf("can't find source file for struct: %s", ftpe.String()) case *types.Interface: decl, found := s.ctx.FindModel(ftpe.Obj().Pkg().Path(), ftpe.Obj().Name()) if found { return s.buildFromInterface(decl, utpe, schema, seen) } - return errors.Errorf("can't find source file for struct: %s", ftpe.String()) + return fmt.Errorf("can't find source file for struct: %s", ftpe.String()) default: log.Printf("WARNING: can't figure out object type for embedded named type (%T): %v", ftpe, ftpe.Underlying()) } |