diff --git a/Dockerfile b/Dockerfile index 3d2682d3..e33e930f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN mkdir /stubs RUN apk -U --no-cache add git protobuf RUN go get -u -v github.com/golang/protobuf/protoc-gen-go \ + github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \ github.com/mitchellh/mapstructure \ google.golang.org/grpc \ google.golang.org/grpc/reflection \ diff --git a/gripmock.go b/gripmock.go index 6aaf49fb..9fd0ce0b 100644 --- a/gripmock.go +++ b/gripmock.go @@ -102,10 +102,13 @@ func generateProtoc(param protocParam) { if len(protodirs) > 0 { protodir = strings.Join(protodirs[:len(protodirs)-1], "/") + "/" } - args := []string{"-I", protodir} // include well-known-types args = append(args, "-I", "/protobuf") + if os.Getenv("GOPATH") != "" { + googlesApisPath := os.Getenv("GOPATH")+"/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/" + args = append(args, "-I", googlesApisPath) + } args = append(args, param.protoPath...) args = append(args, "--go_out=plugins=grpc:"+param.output) args = append(args, fmt.Sprintf("--gripmock_out=admin-port=%s,grpc-address=%s,grpc-port=%s:%s", diff --git a/protoc-gen-gripmock/generator.go b/protoc-gen-gripmock/generator.go index 01c70c34..37e68465 100644 --- a/protoc-gen-gripmock/generator.go +++ b/protoc-gen-gripmock/generator.go @@ -169,6 +169,13 @@ func resolveDependencies(protos []*descriptor.FileDescriptorProto) map[string]st continue } + // some package declarations use a semicolon, which causes a formatting error + // use the alias instead, if available + var sections = strings.Split(pkg, ";") + if len(sections) > 1 { + pkg = sections[1] + } + alias := getAlias(proto.GetName()) // in case of found same alias if ok := aliases[alias]; ok {