Skip to content

Commit

Permalink
fix(deps): replace all uses of golang/protobuf/protobuf (#3516)
Browse files Browse the repository at this point in the history
* fix(deps): replace all uses of golang/protobuf/protobuf

Signed-off-by: aimuz <mr.imuz@gmail.com>

* update protoc-gen-openapiv2/internal/genopenapi/BUILD.bazel

Signed-off-by: aimuz <mr.imuz@gmail.com>

---------

Signed-off-by: aimuz <mr.imuz@gmail.com>
  • Loading branch information
aimuz committed Aug 22, 2023
1 parent 5f9bb5c commit a0ab79a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.17
require (
github.com/antihax/optional v1.0.0
github.com/golang/glog v1.1.0
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.5.9
github.com/rogpeppe/fastuuid v1.2.0
golang.org/x/oauth2 v0.11.0
Expand All @@ -18,6 +17,7 @@ require (
)

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/kr/pretty v0.3.1 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions protoc-gen-openapiv2/internal/genopenapi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ go_library(
"//internal/descriptor",
"//internal/generator",
"//protoc-gen-openapiv2/options",
"@com_github_golang_protobuf//descriptor:go_default_library_gen",
"@com_github_golang_protobuf//ptypes/any",
"@in_gopkg_yaml_v3//:yaml_v3",
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_genproto_googleapis_api//visibility",
"@org_golang_google_genproto_googleapis_rpc//status",
"@org_golang_google_grpc//grpclog",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//proto",
"@org_golang_google_protobuf//reflect/protodesc",
"@org_golang_google_protobuf//types/descriptorpb",
"@org_golang_google_protobuf//types/known/anypb",
"@org_golang_google_protobuf//types/known/structpb",
"@org_golang_google_protobuf//types/pluginpb",
"@org_golang_x_text//cases",
Expand Down
19 changes: 6 additions & 13 deletions protoc-gen-openapiv2/internal/genopenapi/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import (
"reflect"
"strings"

anypb "github.com/golang/protobuf/ptypes/any"
"github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor"
gen "github.com/grpc-ecosystem/grpc-gateway/v2/internal/generator"
openapi_options "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
openapioptions "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
statuspb "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc/grpclog"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/pluginpb"

//nolint:staticcheck // Known issue, will be replaced when possible
legacydescriptor "github.com/golang/protobuf/descriptor"
)

var errNoTargetService = errors.New("no target service defined in the file")
Expand Down Expand Up @@ -300,7 +298,7 @@ func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.Response
var mergedTarget *descriptor.File
// try to find proto leader
for _, f := range targets {
if proto.HasExtension(f.Options, openapi_options.E_Openapiv2Swagger) {
if proto.HasExtension(f.Options, openapioptions.E_Openapiv2Swagger) {
mergedTarget = f
break
}
Expand Down Expand Up @@ -370,13 +368,8 @@ func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.Response
// to registry (used for error-related API responses)
func AddErrorDefs(reg *descriptor.Registry) error {
// load internal protos
any, _ := legacydescriptor.MessageDescriptorProto(&anypb.Any{})
any.SourceCodeInfo = new(descriptorpb.SourceCodeInfo)
status, _ := legacydescriptor.MessageDescriptorProto(&statuspb.Status{})
status.SourceCodeInfo = new(descriptorpb.SourceCodeInfo)
// TODO(johanbrandhorst): Use new conversion later when possible
// any := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile())
// status := protodesc.ToFileDescriptorProto((&statuspb.Status{}).ProtoReflect().Descriptor().ParentFile())
any := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile())
status := protodesc.ToFileDescriptorProto((&statuspb.Status{}).ProtoReflect().Descriptor().ParentFile())
return reg.Load(&pluginpb.CodeGeneratorRequest{
ProtoFile: []*descriptorpb.FileDescriptorProto{
any,
Expand Down

0 comments on commit a0ab79a

Please sign in to comment.