diff --git a/http.go b/http.go index ffd0a7b..8fc04ab 100644 --- a/http.go +++ b/http.go @@ -41,7 +41,7 @@ func (g *Generator) httpGenerate(component string, plugin *protogen.Plugin, genC for _, service := range file.Services { if genClient { g.generateServiceClient(gfile, service) - g.generateServiceClientMethods(gfile, service, true) + g.generateServiceClientMethods(gfile, service, component) } if genServer { generateServiceServer(gfile, service) diff --git a/main.go b/main.go index 5a5b9b2..9b18889 100644 --- a/main.go +++ b/main.go @@ -90,7 +90,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error { case "http": err = g.httpGenerate(component, plugin, genClient, genServer) case "grpc", "drpc", "rpc": - err = g.rpcGenerate("rpc", plugin, genClient, genServer) + err = g.rpcGenerate(component, plugin, genClient, genServer) case "gorilla": err = g.gorillaGenerate(component, plugin) case "chi": diff --git a/rpc.go b/rpc.go index 0efdd03..ab0bedb 100644 --- a/rpc.go +++ b/rpc.go @@ -38,7 +38,7 @@ func (g *Generator) rpcGenerate(component string, plugin *protogen.Plugin, genCl for _, service := range file.Services { if genClient { g.generateServiceClient(gfile, service) - g.generateServiceClientMethods(gfile, service, false) + g.generateServiceClientMethods(gfile, service, component) } if genServer { generateServiceServer(gfile, service) diff --git a/util.go b/util.go index d9a93e8..be1a34b 100644 --- a/util.go +++ b/util.go @@ -45,13 +45,16 @@ func (g *Generator) generateServiceClient(gfile *protogen.GeneratedFile, service gfile.P() } -func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, http bool) { +func (g *Generator) generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protogen.Service, component string) { serviceName := service.GoName for _, method := range service.Methods { methodName := fmt.Sprintf("%s.%s", serviceName, method.GoName) + if component == "drpc" { + methodName = fmt.Sprintf("%s.%s", method.Parent.Desc.FullName(), method.Desc.Name()) + } g.generateClientFuncSignature(gfile, serviceName, method) - if http && method.Desc.Options() != nil { + if component == "http" && method.Desc.Options() != nil { if proto.HasExtension(method.Desc.Options(), v2.E_Openapiv2Operation) { opts := proto.GetExtension(method.Desc.Options(), v2.E_Openapiv2Operation) if opts != nil {