mirror of
https://github.com/beego/bee.git
synced 2024-11-22 10:10:53 +00:00
commit
76a4feb17e
@ -614,10 +614,25 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error {
|
|||||||
pp := strings.Split(p[2], ".")
|
pp := strings.Split(p[2], ".")
|
||||||
typ := pp[len(pp)-1]
|
typ := pp[len(pp)-1]
|
||||||
if len(pp) >= 2 {
|
if len(pp) >= 2 {
|
||||||
m, mod, realTypes := getModel(p[2])
|
isArray := false
|
||||||
para.Schema = &swagger.Schema{
|
if p[1] == "body" && strings.HasPrefix(p[2], "[]") {
|
||||||
Ref: "#/definitions/" + m,
|
p[2] = p[2][2:]
|
||||||
|
isArray = true
|
||||||
}
|
}
|
||||||
|
m, mod, realTypes := getModel(p[2])
|
||||||
|
if isArray {
|
||||||
|
para.Schema = &swagger.Schema{
|
||||||
|
Type: "array",
|
||||||
|
Items: &swagger.Schema{
|
||||||
|
Ref: "#/definitions/" + m,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
para.Schema = &swagger.Schema{
|
||||||
|
Ref: "#/definitions/" + m,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := modelsList[pkgpath+controllerName]; !ok {
|
if _, ok := modelsList[pkgpath+controllerName]; !ok {
|
||||||
modelsList[pkgpath+controllerName] = make(map[string]swagger.Schema)
|
modelsList[pkgpath+controllerName] = make(map[string]swagger.Schema)
|
||||||
}
|
}
|
||||||
@ -766,10 +781,20 @@ func setParamType(para *swagger.Parameter, typ string, pkgpath, controllerName s
|
|||||||
appendModels(pkgpath, controllerName, realTypes)
|
appendModels(pkgpath, controllerName, realTypes)
|
||||||
}
|
}
|
||||||
if isArray {
|
if isArray {
|
||||||
para.Type = "array"
|
if para.In == "body" {
|
||||||
para.Items = &swagger.ParameterItems{
|
para.Schema = &swagger.Schema{
|
||||||
Type: paraType,
|
Type: "array",
|
||||||
Format: paraFormat,
|
Items: &swagger.Schema{
|
||||||
|
Type: paraType,
|
||||||
|
Format: paraFormat,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
para.Type = "array"
|
||||||
|
para.Items = &swagger.ParameterItems{
|
||||||
|
Type: paraType,
|
||||||
|
Format: paraFormat,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
para.Type = paraType
|
para.Type = paraType
|
||||||
|
Loading…
Reference in New Issue
Block a user