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

添加自定义的对象显示类型

This commit is contained in:
wucheng 2020-08-26 17:22:57 +08:00
parent 2c673b7d1e
commit b45ded3355

View File

@ -93,6 +93,10 @@ var stdlibObject = map[string]string{
"&{json RawMessage}": "json.RawMessage",
}
var customObject = map[string]string{
"&{base ObjectID}": "string",
}
func init() {
pkgCache = make(map[string]struct{})
controllerComments = make(map[string]string)
@ -1236,6 +1240,9 @@ func typeAnalyser(f *ast.Field) (isSlice bool, realType, swaggerType string) {
if isBasicType(fmt.Sprint(arr.Elt)) {
return true, fmt.Sprintf("[]%v", arr.Elt), basicTypes[fmt.Sprint(arr.Elt)]
}
if object, isCustomObject := customObject[fmt.Sprint(arr.Elt)]; isCustomObject {
return true, fmt.Sprintf("[]%v", object), basicTypes[object]
}
if mp, ok := arr.Elt.(*ast.MapType); ok {
return false, fmt.Sprintf("map[%v][%v]", mp.Key, mp.Value), astTypeObject
}