diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 9d335c2..96a6110 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -78,7 +78,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{ @@ -1051,7 +1051,7 @@ func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]s isObject := false 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], @@ -1198,6 +1198,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 }