From 521e9a3bc0e542a4edecf106b379300eefcef395 Mon Sep 17 00:00:00 2001 From: "Yang, Gao" Date: Wed, 10 Apr 2019 23:32:55 +0800 Subject: [PATCH] [Fix] Fix swagger docs missing schema attr for primitive body type @Param annotation --- generate/swaggergen/g_docs.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 2ef09d2..512e01c 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -791,10 +791,21 @@ func setParamType(para *swagger.Parameter, typ string, pkgpath, controllerName s if typ == "string" || typ == "number" || typ == "integer" || typ == "boolean" || typ == astTypeArray || typ == "file" { paraType = typ + if para.In == "body" { + para.Schema = &swagger.Schema{ + Type: paraType, + } + } } else if sType, ok := basicTypes[typ]; ok { typeFormat := strings.Split(sType, ":") paraType = typeFormat[0] paraFormat = typeFormat[1] + if para.In == "body" { + para.Schema = &swagger.Schema{ + Type: paraType, + Format: paraFormat, + } + } } else { m, mod, realTypes := getModel(typ) para.Schema = &swagger.Schema{