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

[Fix] Fix swagger docs missing schema attr for primitive body type @Param annotation

This commit is contained in:
Yang, Gao 2019-04-10 23:32:55 +08:00
parent 36a17c40b0
commit 521e9a3bc0

View File

@ -791,10 +791,21 @@ func setParamType(para *swagger.Parameter, typ string, pkgpath, controllerName s
if typ == "string" || typ == "number" || typ == "integer" || typ == "boolean" || if typ == "string" || typ == "number" || typ == "integer" || typ == "boolean" ||
typ == astTypeArray || typ == "file" { typ == astTypeArray || typ == "file" {
paraType = typ paraType = typ
if para.In == "body" {
para.Schema = &swagger.Schema{
Type: paraType,
}
}
} else if sType, ok := basicTypes[typ]; ok { } else if sType, ok := basicTypes[typ]; ok {
typeFormat := strings.Split(sType, ":") typeFormat := strings.Split(sType, ":")
paraType = typeFormat[0] paraType = typeFormat[0]
paraFormat = typeFormat[1] paraFormat = typeFormat[1]
if para.In == "body" {
para.Schema = &swagger.Schema{
Type: paraType,
Format: paraFormat,
}
}
} else { } else {
m, mod, realTypes := getModel(typ) m, mod, realTypes := getModel(typ)
para.Schema = &swagger.Schema{ para.Schema = &swagger.Schema{