Skip to content

Commit

Permalink
fix(deps): replace all uses of golang/protobuf/protobuf
Browse files Browse the repository at this point in the history
Signed-off-by: aimuz <[email protected]>
  • Loading branch information
aimuz committed Aug 21, 2023
1 parent 71b00e2 commit 8d023e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 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
20 changes: 7 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 @@ -73,6 +71,7 @@ func mergeTargetFile(targets []*wrapper, mergeFileName string) *wrapper {
return mergedTarget
}

// MarshalJSON ...
// Q: What's up with the alias types here?
// A: We don't want to completely override how these structs are marshaled into
// JSON, we only want to add fields (see below, extensionMarshalJSON).
Expand Down Expand Up @@ -300,7 +299,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 +369,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 8d023e5

Please sign in to comment.