Merge pull request #595 from maxshine/develop

Fix swagger docs missing schema attr for primitive body type param
This commit is contained in:
Faissal Elamraoui 2019-04-10 18:08:26 +02:00 committed by GitHub
commit 6f1ff54713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

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{