From bb68873f45713334c5e75620b201656a415f7145 Mon Sep 17 00:00:00 2001 From: guoshaowei Date: Thu, 10 May 2018 14:37:03 +0800 Subject: [PATCH] fix *time.Time type parse error. --- cmd/commands/version/version.go | 2 +- generate/swaggergen/g_docs.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/commands/version/version.go b/cmd/commands/version/version.go index ada9427..fd9b249 100644 --- a/cmd/commands/version/version.go +++ b/cmd/commands/version/version.go @@ -57,7 +57,7 @@ Prints the current Bee, Beego and Go version alongside the platform information. } var outputFormat string -const version = "1.9.1" +const version = "1.9.2" func init() { fs := flag.NewFlagSet("version", flag.ContinueOnError) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 642c263..8c2f060 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -77,7 +77,7 @@ var basicTypes = map[string]string{ "byte": "string:byte", "rune": "string:byte", // builtin golang objects - "time.Time": "string:string", + "time.Time": "string:datetime", } var stdlibObject = map[string]string{ @@ -919,7 +919,7 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string mp := swagger.Propertie{} if isSlice { mp.Type = "array" - if isBasicType(strings.Replace(realType, "[]", "", -1)) { + if sType, ok := basicTypes[(strings.Replace(realType, "[]", "", -1))]; ok { typeFormat := strings.Split(sType, ":") mp.Items = &swagger.Propertie{ Type: typeFormat[0], @@ -1035,6 +1035,9 @@ func typeAnalyser(f *ast.Field) (isSlice bool, realType, swaggerType string) { switch t := f.Type.(type) { case *ast.StarExpr: basicType := fmt.Sprint(t.X) + if object, isStdLibObject := stdlibObject[basicType]; isStdLibObject { + basicType = object + } if k, ok := basicTypes[basicType]; ok { return false, basicType, k }