Skip to content

Commit db71874

Browse files
committed
fix(deps): replace all uses of golang/protobuf/protobuf
Signed-off-by: aimuz <[email protected]>
1 parent 9b47d55 commit db71874

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.17
55
require (
66
github.com/antihax/optional v1.0.0
77
github.com/golang/glog v1.1.0
8-
github.com/golang/protobuf v1.5.3
98
github.com/google/go-cmp v0.5.9
109
github.com/rogpeppe/fastuuid v1.2.0
1110
golang.org/x/oauth2 v0.11.0
@@ -18,6 +17,7 @@ require (
1817
)
1918

2019
require (
20+
github.com/golang/protobuf v1.5.3 // indirect
2121
github.com/kr/pretty v0.3.1 // indirect
2222
golang.org/x/net v0.14.0 // indirect
2323
golang.org/x/sys v0.11.0 // indirect

protoc-gen-openapiv2/internal/genopenapi/generator.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@ import (
99
"reflect"
1010
"strings"
1111

12-
anypb "github.com/golang/protobuf/ptypes/any"
1312
"github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor"
1413
gen "github.com/grpc-ecosystem/grpc-gateway/v2/internal/generator"
15-
openapi_options "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
14+
openapioptions "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
1615
statuspb "google.golang.org/genproto/googleapis/rpc/status"
1716
"google.golang.org/grpc/grpclog"
1817
"google.golang.org/protobuf/proto"
18+
"google.golang.org/protobuf/reflect/protodesc"
1919
"google.golang.org/protobuf/types/descriptorpb"
20+
"google.golang.org/protobuf/types/known/anypb"
2021
"google.golang.org/protobuf/types/pluginpb"
21-
22-
//nolint:staticcheck // Known issue, will be replaced when possible
23-
legacydescriptor "github.com/golang/protobuf/descriptor"
2422
)
2523

2624
var errNoTargetService = errors.New("no target service defined in the file")
@@ -73,6 +71,7 @@ func mergeTargetFile(targets []*wrapper, mergeFileName string) *wrapper {
7371
return mergedTarget
7472
}
7573

74+
// MarshalJSON ...
7675
// Q: What's up with the alias types here?
7776
// A: We don't want to completely override how these structs are marshaled into
7877
// JSON, we only want to add fields (see below, extensionMarshalJSON).
@@ -300,7 +299,7 @@ func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.Response
300299
var mergedTarget *descriptor.File
301300
// try to find proto leader
302301
for _, f := range targets {
303-
if proto.HasExtension(f.Options, openapi_options.E_Openapiv2Swagger) {
302+
if proto.HasExtension(f.Options, openapioptions.E_Openapiv2Swagger) {
304303
mergedTarget = f
305304
break
306305
}
@@ -370,13 +369,8 @@ func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.Response
370369
// to registry (used for error-related API responses)
371370
func AddErrorDefs(reg *descriptor.Registry) error {
372371
// load internal protos
373-
any, _ := legacydescriptor.MessageDescriptorProto(&anypb.Any{})
374-
any.SourceCodeInfo = new(descriptorpb.SourceCodeInfo)
375-
status, _ := legacydescriptor.MessageDescriptorProto(&statuspb.Status{})
376-
status.SourceCodeInfo = new(descriptorpb.SourceCodeInfo)
377-
// TODO(johanbrandhorst): Use new conversion later when possible
378-
// any := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile())
379-
// status := protodesc.ToFileDescriptorProto((&statuspb.Status{}).ProtoReflect().Descriptor().ParentFile())
372+
any := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile())
373+
status := protodesc.ToFileDescriptorProto((&statuspb.Status{}).ProtoReflect().Descriptor().ParentFile())
380374
return reg.Load(&pluginpb.CodeGeneratorRequest{
381375
ProtoFile: []*descriptorpb.FileDescriptorProto{
382376
any,

0 commit comments

Comments
 (0)