mirror of
https://github.com/beego/bee.git
synced 2024-12-22 10:00:50 +00:00
添加自定义的对象显示类型
This commit is contained in:
parent
2c673b7d1e
commit
b45ded3355
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user