1
0
mirror of https://github.com/beego/bee.git synced 2024-11-24 08:30:53 +00:00

fix *time.Time type parse error.

This commit is contained in:
guoshaowei 2018-05-10 14:37:03 +08:00
parent e90da8f77b
commit bb68873f45
2 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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
}