diff --git a/internal/main.go b/internal/main.go index c56a42f..d240cf2 100644 --- a/internal/main.go +++ b/internal/main.go @@ -321,16 +321,21 @@ func genXService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generate for _, p := range httpParam.UrlParamList { g.P("// @Param ", p.PName, " path ", p.PType, " true ", `"some id"`) } - for _, ff := range value.Input.Fields { - query := "query" - if httpParam.MethodName == "POST" || httpParam.MethodName == "PATCH" { - query = "body" - } - fp := utils.ParseFieldLeading(ff) - if len(fp.FTail) > 0 { - g.P("// @Param ", fp.FName, " ", query, " ", fp.FType, " ", fp.FRequired, ` "`, fp.FTail, `" `, fp.GetEnums()) - } else { - g.P("// @Param ", fp.FName, " ", query, " ", fp.FType, " ", fp.FRequired, ` "参数无注释" `, fp.GetEnums()) + + if httpParam.MethodName == "POST" || httpParam.MethodName == "PATCH" { + g.P(`// @Param data body `, value.Input.GoIdent.GoName, ` true "body 参数"`) + } else { + for _, ff := range value.Input.Fields { + query := "query" + if httpParam.MethodName == "POST" || httpParam.MethodName == "PATCH" { + query = "body" + } + fp := utils.ParseFieldLeading(ff) + if len(fp.FTail) > 0 { + g.P("// @Param ", fp.FName, " ", query, " ", fp.FType, " ", fp.FRequired, ` "`, fp.FTail, `" `, fp.GetEnums()) + } else { + g.P("// @Param ", fp.FName, " ", query, " ", fp.FType, " ", fp.FRequired, ` "参数无注释" `, fp.GetEnums()) + } } } diff --git a/internal/utils/common.go b/internal/utils/common.go index af05d0a..8e4b0ba 100644 --- a/internal/utils/common.go +++ b/internal/utils/common.go @@ -1,6 +1,6 @@ package utils -var VERSION = "1.3.3" +var VERSION = "1.3.4" const DeprecationComment = "// Deprecated: Do not use." const StringType = "string"