From 7aec59cc311f4528d1a9d5b64d6020453ca97ca9 Mon Sep 17 00:00:00 2001 From: Yuki Yugui Sonoda Date: Mon, 13 Jun 2016 18:07:26 +0900 Subject: [PATCH] Use google.protobuf.Empty instead of our own --- examples/examplepb/a_bit_of_everything.pb.go | 190 +++++++++--------- .../examplepb/a_bit_of_everything.pb.gw.go | 3 +- examples/examplepb/a_bit_of_everything.proto | 12 +- .../a_bit_of_everything.swagger.json | 16 +- examples/examplepb/echo_service.pb.go | 1 - examples/examplepb/stream.pb.go | 61 +++--- examples/examplepb/stream.pb.gw.go | 3 +- examples/examplepb/stream.proto | 5 +- examples/integration_test.go | 3 +- examples/server/a_bit_of_everything.go | 15 +- 10 files changed, 153 insertions(+), 156 deletions(-) diff --git a/examples/examplepb/a_bit_of_everything.pb.go b/examples/examplepb/a_bit_of_everything.pb.go index 09f9274cdce..0cc2f023fc1 100644 --- a/examples/examplepb/a_bit_of_everything.pb.go +++ b/examples/examplepb/a_bit_of_everything.pb.go @@ -8,6 +8,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "github.com/gengo/grpc-gateway/third_party/googleapis/google/api" +import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" import gengo_grpc_gateway_examples_sub "github.com/gengo/grpc-gateway/examples/sub" import sub2 "github.com/gengo/grpc-gateway/examples/sub2" @@ -114,7 +115,7 @@ type isABitOfEverything_OneofValue interface { } type ABitOfEverything_OneofEmpty struct { - OneofEmpty *EmptyMessage `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` + OneofEmpty *google_protobuf1.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` } type ABitOfEverything_OneofString struct { OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,oneof"` @@ -144,7 +145,7 @@ func (m *ABitOfEverything) GetNested() []*ABitOfEverything_Nested { return nil } -func (m *ABitOfEverything) GetOneofEmpty() *EmptyMessage { +func (m *ABitOfEverything) GetOneofEmpty() *google_protobuf1.Empty { if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofEmpty); ok { return x.OneofEmpty } @@ -213,7 +214,7 @@ func _ABitOfEverything_OneofUnmarshaler(msg proto.Message, tag, wire int, b *pro if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - msg := new(EmptyMessage) + msg := new(google_protobuf1.Empty) err := b.DecodeMessage(msg) m.OneofValue = &ABitOfEverything_OneofEmpty{msg} return true, err @@ -262,18 +263,9 @@ func (m *ABitOfEverything_Nested) String() string { return proto.Comp func (*ABitOfEverything_Nested) ProtoMessage() {} func (*ABitOfEverything_Nested) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0, 0} } -type EmptyMessage struct { -} - -func (m *EmptyMessage) Reset() { *m = EmptyMessage{} } -func (m *EmptyMessage) String() string { return proto.CompactTextString(m) } -func (*EmptyMessage) ProtoMessage() {} -func (*EmptyMessage) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} } - func init() { proto.RegisterType((*ABitOfEverything)(nil), "gengo.grpc.gateway.examples.examplepb.ABitOfEverything") proto.RegisterType((*ABitOfEverything_Nested)(nil), "gengo.grpc.gateway.examples.examplepb.ABitOfEverything.Nested") - proto.RegisterType((*EmptyMessage)(nil), "gengo.grpc.gateway.examples.examplepb.EmptyMessage") proto.RegisterEnum("gengo.grpc.gateway.examples.examplepb.NumericEnum", NumericEnum_name, NumericEnum_value) proto.RegisterEnum("gengo.grpc.gateway.examples.examplepb.ABitOfEverything_Nested_DeepEnum", ABitOfEverything_Nested_DeepEnum_name, ABitOfEverything_Nested_DeepEnum_value) } @@ -292,11 +284,11 @@ type ABitOfEverythingServiceClient interface { Create(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) CreateBody(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) Lookup(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*ABitOfEverything, error) - Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*EmptyMessage, error) - Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*EmptyMessage, error) + Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Echo(ctx context.Context, in *gengo_grpc_gateway_examples_sub.StringMessage, opts ...grpc.CallOption) (*gengo_grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) - Timeout(ctx context.Context, in *EmptyMessage, opts ...grpc.CallOption) (*EmptyMessage, error) + Timeout(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) } type aBitOfEverythingServiceClient struct { @@ -334,8 +326,8 @@ func (c *aBitOfEverythingServiceClient) Lookup(ctx context.Context, in *sub2.IdM return out, nil } -func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*EmptyMessage, error) { - out := new(EmptyMessage) +func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Update", in, out, c.cc, opts...) if err != nil { return nil, err @@ -343,8 +335,8 @@ func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEv return out, nil } -func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*EmptyMessage, error) { - out := new(EmptyMessage) +func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Delete", in, out, c.cc, opts...) if err != nil { return nil, err @@ -370,8 +362,8 @@ func (c *aBitOfEverythingServiceClient) DeepPathEcho(ctx context.Context, in *AB return out, nil } -func (c *aBitOfEverythingServiceClient) Timeout(ctx context.Context, in *EmptyMessage, opts ...grpc.CallOption) (*EmptyMessage, error) { - out := new(EmptyMessage) +func (c *aBitOfEverythingServiceClient) Timeout(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Timeout", in, out, c.cc, opts...) if err != nil { return nil, err @@ -385,11 +377,11 @@ type ABitOfEverythingServiceServer interface { Create(context.Context, *ABitOfEverything) (*ABitOfEverything, error) CreateBody(context.Context, *ABitOfEverything) (*ABitOfEverything, error) Lookup(context.Context, *sub2.IdMessage) (*ABitOfEverything, error) - Update(context.Context, *ABitOfEverything) (*EmptyMessage, error) - Delete(context.Context, *sub2.IdMessage) (*EmptyMessage, error) + Update(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) + Delete(context.Context, *sub2.IdMessage) (*google_protobuf1.Empty, error) Echo(context.Context, *gengo_grpc_gateway_examples_sub.StringMessage) (*gengo_grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(context.Context, *ABitOfEverything) (*ABitOfEverything, error) - Timeout(context.Context, *EmptyMessage) (*EmptyMessage, error) + Timeout(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) } func RegisterABitOfEverythingServiceServer(s *grpc.Server, srv ABitOfEverythingServiceServer) { @@ -523,7 +515,7 @@ func _ABitOfEverythingService_DeepPathEcho_Handler(srv interface{}, ctx context. } func _ABitOfEverythingService_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EmptyMessage) + in := new(google_protobuf1.Empty) if err := dec(in); err != nil { return nil, err } @@ -535,7 +527,7 @@ func _ABitOfEverythingService_Timeout_Handler(srv interface{}, ctx context.Conte FullMethod: "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Timeout", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ABitOfEverythingServiceServer).Timeout(ctx, req.(*EmptyMessage)) + return srv.(ABitOfEverythingServiceServer).Timeout(ctx, req.(*google_protobuf1.Empty)) } return interceptor(ctx, in, info, handler) } @@ -583,77 +575,77 @@ var _ABitOfEverythingService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/a_bit_of_everything.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 1152 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xc4, 0x57, 0xed, 0x6e, 0x1b, 0x45, - 0x17, 0xee, 0xda, 0x89, 0x13, 0x1f, 0x7f, 0xc4, 0x99, 0x34, 0xa9, 0xeb, 0xbe, 0xaf, 0x12, 0x0c, - 0x45, 0x55, 0xa8, 0x76, 0xd5, 0x4d, 0xc5, 0x47, 0x24, 0x40, 0x4d, 0x63, 0x28, 0x52, 0x9b, 0xc0, - 0x26, 0x0d, 0x52, 0x24, 0x64, 0xad, 0xed, 0x89, 0xb3, 0x8a, 0x77, 0x67, 0xb5, 0x1f, 0xa6, 0x56, - 0x94, 0xfe, 0xa8, 0xb8, 0x00, 0x24, 0x2e, 0x01, 0x09, 0x89, 0x4a, 0x70, 0x0f, 0xfc, 0x44, 0xfc, - 0xe4, 0x16, 0xb8, 0x01, 0xee, 0x80, 0xb3, 0x33, 0xbb, 0x9b, 0x59, 0x27, 0x25, 0xc1, 0xa9, 0xe0, - 0x97, 0x77, 0xce, 0x3c, 0xfb, 0x9c, 0xe7, 0x9c, 0x33, 0xe7, 0xcc, 0x1a, 0xee, 0xd2, 0x67, 0xa6, - 0xed, 0x0e, 0xa8, 0xaf, 0xc5, 0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0x8c, 0x58, 0x20, 0xa6, 0x10, - 0xa1, 0x18, 0x25, 0x61, 0x13, 0x10, 0xe4, 0xb0, 0x9c, 0xe0, 0xdd, 0xfb, 0x31, 0x62, 0x1a, 0x11, - 0x79, 0x03, 0xb8, 0x29, 0xe5, 0x08, 0x65, 0x44, 0x01, 0x11, 0x53, 0x46, 0x29, 0x94, 0x20, 0x82, - 0x63, 0x4d, 0x8f, 0x11, 0x33, 0x88, 0x98, 0xe6, 0x1c, 0x6b, 0xba, 0x00, 0xbc, 0x09, 0x95, 0x03, - 0xeb, 0x19, 0xed, 0xa5, 0x24, 0xb3, 0x08, 0x29, 0x18, 0xe5, 0xd8, 0x98, 0x05, 0xa5, 0x3c, 0x45, - 0x04, 0xcd, 0xc4, 0xa0, 0x84, 0xe9, 0xff, 0x00, 0x1d, 0xc6, 0x06, 0x31, 0x02, 0x10, 0x31, 0x6b, - 0x14, 0x23, 0x4b, 0x2a, 0xd6, 0x0f, 0x3c, 0x4c, 0x55, 0x0c, 0x28, 0xf1, 0x2a, 0x94, 0x84, 0x2d, - 0x13, 0x4f, 0xea, 0xa5, 0x82, 0x90, 0x8a, 0x88, 0x27, 0x71, 0xf2, 0x05, 0x00, 0x75, 0x42, 0x3b, - 0x06, 0x54, 0x11, 0x50, 0xd5, 0xf5, 0x4b, 0xd6, 0x6c, 0x2b, 0xb4, 0xa9, 0x67, 0x75, 0x5b, 0xf8, - 0xbe, 0x51, 0x8c, 0x58, 0x04, 0xe5, 0x6d, 0xa8, 0xfa, 0xd9, 0xe8, 0xe6, 0x90, 0x76, 0xce, 0xa8, - 0xf8, 0x99, 0xf0, 0x52, 0x58, 0x9a, 0xa9, 0x1a, 0xc2, 0x6a, 0x09, 0x4c, 0xaa, 0x89, 0x2f, 0xc7, - 0x30, 0x8f, 0xa0, 0x79, 0x0c, 0x53, 0x8a, 0x21, 0x86, 0xa4, 0x3c, 0x04, 0x21, 0x44, 0x40, 0x12, - 0x16, 0x1d, 0x16, 0x3d, 0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 0x54, 0x31, 0x56, 0x13, 0x75, 0xff, 0x10, 0xdf, 0xec, 0x72, 0x61, - 0x5f, 0x91, 0xbb, 0x17, 0x09, 0xa3, 0xa8, 0x46, 0x3b, 0x16, 0x7d, 0xb1, 0x7f, 0xb3, 0x59, 0xd3, - 0x86, 0x7a, 0x8a, 0x8f, 0xf6, 0xd6, 0xc5, 0x94, 0xdc, 0x27, 0xe4, 0xcc, 0x16, 0xf9, 0x45, 0x81, - 0x72, 0x74, 0x2b, 0x7d, 0x6e, 0x06, 0x87, 0x3c, 0xaa, 0x7f, 0xbf, 0x5b, 0x3e, 0xe6, 0x71, 0x7e, - 0xd0, 0xbc, 0x7f, 0x61, 0x01, 0x32, 0xff, 0x97, 0xd4, 0xe8, 0x16, 0xe7, 0x27, 0xe2, 0x5b, 0x05, - 0x66, 0x76, 0x2d, 0x9b, 0xb2, 0x30, 0x20, 0x93, 0x1c, 0x81, 0xc9, 0xce, 0xcd, 0x2d, 0x2e, 0x7b, - 0x91, 0x2c, 0xc8, 0x39, 0x0d, 0x84, 0x8c, 0x8d, 0xd2, 0x7e, 0x31, 0x7d, 0xad, 0x53, 0xe0, 0xff, - 0x02, 0xd7, 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x0c, 0xd8, 0x3f, 0xb9, 0xb3, 0x0e, 0x00, 0x00, + // 1150 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xc4, 0x57, 0xdd, 0x6e, 0x1b, 0x45, + 0x14, 0xee, 0xda, 0x89, 0x13, 0x9f, 0x8d, 0x53, 0x67, 0xd2, 0xa4, 0xae, 0x0b, 0x4a, 0x30, 0x14, + 0x55, 0xa1, 0xda, 0x55, 0x37, 0x15, 0xd0, 0x48, 0x80, 0x9a, 0xc6, 0x50, 0xa4, 0x36, 0x81, 0x4d, + 0x1a, 0xa4, 0x48, 0xc8, 0x5a, 0xdb, 0x13, 0x67, 0x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4f, 0xb5, + 0x0b, 0xc5, 0xa1, 0x8d, 0xf2, 0x69, 0x9b, 0x9c, 0xc5, 0x9c, 0x11, 0xa4, 0x62, 0x45, 0x08, 0x4c, + 0x44, 0x91, 0xdd, 0xad, 0x29, 0xc8, 0x5d, 0x36, 0xf9, 0x37, 0xd9, 0x85, 0x52, 0x62, 0xb1, 0xb0, + 0x5c, 0x7c, 0x03, 0x16, 0x13, 0x36, 0xb2, 0x04, 0xea, 0x7e, 0x9f, 0x59, 0x61, 0x6b, 0x60, 0xf5, + 0x23, 0x5a, 0x2b, 0xa2, 0xc9, 0x82, 0x09, 0x5c, 0xb4, 0x1b, 0x4b, 0xc8, 0x3b, 0x30, 0xd3, 0x65, + 0x51, 0x1b, 0x23, 0x16, 0x88, 0x09, 0x44, 0x28, 0xa6, 0x2a, 0x64, 0x02, 0x82, 0x1c, 0xb6, 0x1b, + 0x7e, 0xf8, 0x20, 0x41, 0x4c, 0x22, 0xa2, 0x68, 0x02, 0x17, 0x65, 0x1c, 0x91, 0x8c, 0x28, 0x21, + 0x62, 0xc2, 0x54, 0x23, 0x09, 0x22, 0x38, 0x56, 0x8d, 0x04, 0x31, 0x85, 0x88, 0x49, 0xce, 0xb1, + 0x6a, 0x08, 0xc0, 0xbb, 0x50, 0xd9, 0xb7, 0x5f, 0xd0, 0x6e, 0x46, 0x32, 0x8d, 0x90, 0x92, 0x39, + 0x93, 0x08, 0xf3, 0xa0, 0x8c, 0xa7, 0x8c, 0xa0, 0xa9, 0x04, 0x94, 0x32, 0xbd, 0x0d, 0xd0, 0x66, + 0xac, 0x9f, 0x20, 0x00, 0x11, 0xd3, 0x66, 0x39, 0x96, 0x64, 0xce, 0x06, 0xa1, 0x8f, 0xa9, 0x4a, + 0x00, 0x2a, 0xaf, 0x82, 0x2a, 0x64, 0xb9, 0x78, 0x32, 0x2b, 0x15, 0x84, 0x54, 0x44, 0x3c, 0xa9, + 0x91, 0xaf, 0x01, 0xa8, 0x1b, 0x39, 0x09, 0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x97, 0xbc, 0x7f, 0xee, 0x71, 0x89, 0x1f, 0x79, + 0xc7, 0xe4, 0x47, 0x74, 0xe2, 0xb9, 0xd7, 0xbd, 0xd2, 0xf1, 0x1e, 0x73, 0x93, 0x36, 0xee, 0x73, + 0x5f, 0x3e, 0xa8, 0x5f, 0xd0, 0x97, 0x38, 0x27, 0x16, 0x94, 0x36, 0x68, 0x9f, 0xa2, 0x37, 0xa7, + 0x52, 0x32, 0xce, 0x4a, 0x12, 0xf1, 0xca, 0x45, 0x23, 0xfe, 0x43, 0x81, 0x89, 0x66, 0xe7, 0x80, + 0x11, 0xed, 0x1f, 0xe3, 0x45, 0xeb, 0x9a, 0x18, 0x86, 0xa9, 0x03, 0xff, 0x12, 0xdf, 0xe8, 0x70, + 0xc7, 0xbe, 0x25, 0xf7, 0xce, 0x73, 0x8c, 0xa2, 0x37, 0xfa, 0x91, 0x38, 0xdd, 0x7b, 0xb7, 0x1a, + 0x55, 0x7d, 0x60, 0x64, 0xf8, 0x58, 0xb7, 0x26, 0x66, 0xdb, 0x1e, 0x21, 0xa7, 0x54, 0xe4, 0x77, + 0x05, 0x66, 0xe2, 0xbb, 0xe4, 0x2b, 0x2b, 0x3c, 0xe0, 0x51, 0xfd, 0xf7, 0x67, 0xfe, 0x33, 0x1e, + 0xe7, 0xc3, 0xc6, 0x83, 0x73, 0x0b, 0x90, 0xfb, 0x23, 0xa3, 0xc5, 0x77, 0x2f, 0x2f, 0xfa, 0x2e, + 0x4c, 0xed, 0xd8, 0x0e, 0x65, 0x51, 0x48, 0xc6, 0x14, 0x79, 0x6c, 0xf1, 0x6f, 0x73, 0xdb, 0x0b, + 0x64, 0x5e, 0x4e, 0x4c, 0x28, 0xc8, 0xd6, 0xd5, 0xbd, 0x72, 0xe6, 0x76, 0xbb, 0xc4, 0x77, 0xae, + 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x9b, 0x03, 0x1c, 0x09, 0x2e, 0x0e, 0x00, 0x00, } diff --git a/examples/examplepb/a_bit_of_everything.pb.gw.go b/examples/examplepb/a_bit_of_everything.pb.gw.go index 1370446fb92..ae91750b167 100644 --- a/examples/examplepb/a_bit_of_everything.pb.gw.go +++ b/examples/examplepb/a_bit_of_everything.pb.gw.go @@ -18,6 +18,7 @@ import ( "github.com/gengo/grpc-gateway/runtime" "github.com/gengo/grpc-gateway/utilities" "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes/empty" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -405,7 +406,7 @@ func request_ABitOfEverythingService_DeepPathEcho_0(ctx context.Context, marshal } func request_ABitOfEverythingService_Timeout_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq EmptyMessage + var protoReq empty.Empty var metadata runtime.ServerMetadata msg, err := client.Timeout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) diff --git a/examples/examplepb/a_bit_of_everything.proto b/examples/examplepb/a_bit_of_everything.proto index 1ebfc631bdf..addd2ebb3bd 100644 --- a/examples/examplepb/a_bit_of_everything.proto +++ b/examples/examplepb/a_bit_of_everything.proto @@ -3,6 +3,7 @@ option go_package = "examplepb"; package gengo.grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; +import "google/protobuf/empty.proto"; import "examples/sub/message.proto"; import "examples/sub2/message.proto"; @@ -45,7 +46,7 @@ message ABitOfEverything { sint64 sint64_value = 18; repeated string repeated_string_value = 19; oneof oneof_value { - EmptyMessage oneof_empty = 20; + google.protobuf.Empty oneof_empty = 20; string oneof_string = 21; } @@ -56,9 +57,6 @@ message ABitOfEverything { string nonConventionalNameValue = 26; } -message EmptyMessage { -} - // NumericEnum is one or zero. enum NumericEnum { // ZERO means 0 @@ -85,13 +83,13 @@ service ABitOfEverythingService { get: "/v1/example/a_bit_of_everything/{uuid}" }; } - rpc Update(ABitOfEverything) returns (EmptyMessage) { + rpc Update(ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { put: "/v1/example/a_bit_of_everything/{uuid}" body: "*" }; } - rpc Delete(sub2.IdMessage) returns (EmptyMessage) { + rpc Delete(sub2.IdMessage) returns (google.protobuf.Empty) { option (google.api.http) = { delete: "/v1/example/a_bit_of_everything/{uuid}" }; @@ -114,7 +112,7 @@ service ABitOfEverythingService { body: "*" }; } - rpc Timeout(EmptyMessage) returns (EmptyMessage) { + rpc Timeout(google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = { get: "/v2/example/timeout", }; diff --git a/examples/examplepb/a_bit_of_everything.swagger.json b/examples/examplepb/a_bit_of_everything.swagger.json index e1ccff0b9da..801180b197c 100644 --- a/examples/examplepb/a_bit_of_everything.swagger.json +++ b/examples/examplepb/a_bit_of_everything.swagger.json @@ -252,7 +252,7 @@ "200": { "description": "Description", "schema": { - "$ref": "#/definitions/examplepbEmptyMessage" + "$ref": "#/definitions/protobufEmpty" } } }, @@ -275,7 +275,7 @@ "200": { "description": "Description", "schema": { - "$ref": "#/definitions/examplepbEmptyMessage" + "$ref": "#/definitions/protobufEmpty" } } }, @@ -348,7 +348,7 @@ "200": { "description": "Description", "schema": { - "$ref": "#/definitions/examplepbEmptyMessage" + "$ref": "#/definitions/protobufEmpty" } } }, @@ -450,7 +450,7 @@ "format": "string" }, "oneof_empty": { - "$ref": "#/definitions/examplepbEmptyMessage" + "$ref": "#/definitions/protobufEmpty" }, "oneof_string": { "type": "string", @@ -502,9 +502,6 @@ }, "title": "Intentionaly complicated message type to cover much features of Protobuf.\nNEXT ID: 27" }, - "examplepbEmptyMessage": { - "type": "object" - }, "examplepbNumericEnum": { "type": "string", "enum": [ @@ -514,6 +511,11 @@ "default": "ZERO", "description": "NumericEnum is one or zero.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1" }, + "protobufEmpty": { + "type": "object", + "description": "service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n }\n\nThe JSON representation for `Empty` is empty JSON object `{}`.", + "title": "A generic empty message that you can re-use to avoid defining duplicated\nempty messages in your APIs. A typical example is to use it as the request\nor the response type of an API method. For instance:" + }, "sub2IdMessage": { "type": "object", "properties": { diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index 35da7c4206e..81d47454bff 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -19,7 +19,6 @@ It is generated from these files: It has these top-level messages: SimpleMessage ABitOfEverything - EmptyMessage EmptyProto NonEmptyProto UnaryProto diff --git a/examples/examplepb/stream.pb.go b/examples/examplepb/stream.pb.go index 3a8bd19e22c..9c9688f8a1d 100644 --- a/examples/examplepb/stream.pb.go +++ b/examples/examplepb/stream.pb.go @@ -8,6 +8,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "github.com/gengo/grpc-gateway/third_party/googleapis/google/api" +import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" import gengo_grpc_gateway_examples_sub "github.com/gengo/grpc-gateway/examples/sub" import ( @@ -32,7 +33,7 @@ const _ = grpc.SupportPackageIsVersion2 type StreamServiceClient interface { BulkCreate(ctx context.Context, opts ...grpc.CallOption) (StreamService_BulkCreateClient, error) - List(ctx context.Context, in *EmptyMessage, opts ...grpc.CallOption) (StreamService_ListClient, error) + List(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) BulkEcho(ctx context.Context, opts ...grpc.CallOption) (StreamService_BulkEchoClient, error) } @@ -55,7 +56,7 @@ func (c *streamServiceClient) BulkCreate(ctx context.Context, opts ...grpc.CallO type StreamService_BulkCreateClient interface { Send(*ABitOfEverything) error - CloseAndRecv() (*EmptyMessage, error) + CloseAndRecv() (*google_protobuf1.Empty, error) grpc.ClientStream } @@ -67,18 +68,18 @@ func (x *streamServiceBulkCreateClient) Send(m *ABitOfEverything) error { return x.ClientStream.SendMsg(m) } -func (x *streamServiceBulkCreateClient) CloseAndRecv() (*EmptyMessage, error) { +func (x *streamServiceBulkCreateClient) CloseAndRecv() (*google_protobuf1.Empty, error) { if err := x.ClientStream.CloseSend(); err != nil { return nil, err } - m := new(EmptyMessage) + m := new(google_protobuf1.Empty) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } return m, nil } -func (c *streamServiceClient) List(ctx context.Context, in *EmptyMessage, opts ...grpc.CallOption) (StreamService_ListClient, error) { +func (c *streamServiceClient) List(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) { stream, err := grpc.NewClientStream(ctx, &_StreamService_serviceDesc.Streams[1], c.cc, "/gengo.grpc.gateway.examples.examplepb.StreamService/List", opts...) if err != nil { return nil, err @@ -145,7 +146,7 @@ func (x *streamServiceBulkEchoClient) Recv() (*gengo_grpc_gateway_examples_sub.S type StreamServiceServer interface { BulkCreate(StreamService_BulkCreateServer) error - List(*EmptyMessage, StreamService_ListServer) error + List(*google_protobuf1.Empty, StreamService_ListServer) error BulkEcho(StreamService_BulkEchoServer) error } @@ -158,7 +159,7 @@ func _StreamService_BulkCreate_Handler(srv interface{}, stream grpc.ServerStream } type StreamService_BulkCreateServer interface { - SendAndClose(*EmptyMessage) error + SendAndClose(*google_protobuf1.Empty) error Recv() (*ABitOfEverything, error) grpc.ServerStream } @@ -167,7 +168,7 @@ type streamServiceBulkCreateServer struct { grpc.ServerStream } -func (x *streamServiceBulkCreateServer) SendAndClose(m *EmptyMessage) error { +func (x *streamServiceBulkCreateServer) SendAndClose(m *google_protobuf1.Empty) error { return x.ServerStream.SendMsg(m) } @@ -180,7 +181,7 @@ func (x *streamServiceBulkCreateServer) Recv() (*ABitOfEverything, error) { } func _StreamService_List_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(EmptyMessage) + m := new(google_protobuf1.Empty) if err := stream.RecvMsg(m); err != nil { return err } @@ -253,25 +254,25 @@ var _StreamService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/stream.proto", fileDescriptor2) } var fileDescriptor2 = []byte{ - // 306 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xad, 0x48, 0xcc, - 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x87, 0x32, 0x0a, 0x92, 0xf4, 0x8b, 0x4b, 0x8a, 0x52, 0x13, 0x73, - 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x54, 0xd3, 0x53, 0xf3, 0xd2, 0xf3, 0xf5, 0xd2, 0x8b, - 0x0a, 0x92, 0xf5, 0xd2, 0x13, 0x4b, 0x52, 0xcb, 0x13, 0x2b, 0xf5, 0x60, 0x7a, 0xf4, 0xe0, 0x7a, - 0xa4, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, - 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0x86, 0x48, 0xe9, 0x60, 0xb1, 0x25, 0x31, - 0x3e, 0x29, 0xb3, 0x24, 0x3e, 0x3f, 0x2d, 0x3e, 0xb5, 0x2c, 0xb5, 0xa8, 0xb2, 0x24, 0x23, 0x33, - 0x2f, 0x1d, 0xaa, 0x5a, 0x0a, 0xae, 0xba, 0xb8, 0x34, 0x49, 0x3f, 0x37, 0xb5, 0xb8, 0x38, 0x31, - 0x3d, 0x15, 0x22, 0x67, 0xd4, 0xcc, 0xc2, 0xc5, 0x1b, 0x0c, 0x76, 0x5f, 0x70, 0x6a, 0x51, 0x59, - 0x66, 0x72, 0xaa, 0xd0, 0x5a, 0x46, 0x2e, 0x2e, 0xa7, 0xd2, 0x9c, 0x6c, 0x67, 0xa0, 0x60, 0x49, - 0xaa, 0x90, 0xb9, 0x1e, 0x51, 0x0e, 0xd6, 0x73, 0x74, 0xca, 0x2c, 0xf1, 0x4f, 0x73, 0x85, 0xdb, - 0x2d, 0x65, 0x4c, 0xa4, 0x46, 0xd7, 0xdc, 0x82, 0x92, 0x4a, 0x5f, 0x88, 0xa3, 0x94, 0xf4, 0x9b, - 0x2e, 0x3f, 0x99, 0xcc, 0xa4, 0xa9, 0xa4, 0xa2, 0x5f, 0x66, 0x08, 0xf3, 0x1b, 0x36, 0x9f, 0xe9, - 0x27, 0x01, 0x5d, 0x68, 0xc5, 0xa8, 0xa5, 0xc1, 0x28, 0x34, 0x9f, 0x91, 0x8b, 0xc5, 0x27, 0xb3, - 0xb8, 0x44, 0x88, 0x1c, 0x0b, 0xa5, 0xc8, 0xf5, 0x9e, 0x92, 0x3a, 0xd8, 0xa5, 0x8a, 0x42, 0xf2, - 0x04, 0x5c, 0x6a, 0x00, 0x76, 0x21, 0x07, 0x28, 0x44, 0x5d, 0x93, 0x33, 0xf2, 0x85, 0xf4, 0xf0, - 0x5a, 0x08, 0x8c, 0x20, 0x3d, 0x60, 0x74, 0x00, 0xf5, 0xc1, 0x1c, 0x48, 0xa2, 0x7a, 0xe2, 0x43, - 0x30, 0x15, 0xe8, 0x1a, 0x70, 0x08, 0x1a, 0x30, 0x3a, 0x71, 0x47, 0x71, 0xc2, 0xbd, 0x9a, 0xc4, - 0x06, 0x4e, 0x19, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb4, 0x53, 0xd5, 0x72, 0xcb, 0x02, - 0x00, 0x00, + // 320 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x90, 0x3b, 0x4e, 0x2b, 0x31, + 0x14, 0x86, 0xe5, 0x7b, 0x11, 0x02, 0x23, 0x1a, 0x17, 0x14, 0x06, 0x29, 0x22, 0x02, 0xf1, 0x10, + 0x3a, 0x0e, 0x50, 0x20, 0xd1, 0x11, 0x94, 0x0e, 0x44, 0x91, 0x8e, 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b, 0x6a, 0xee, 0x89, 0xc9, 0x69, 0x85, 0xbf, 0x08, 0x5e, 0xa8, 0x08, 0x71, 0x49, 0x8e, + 0x0f, 0x09, 0x9b, 0x11, 0xba, 0x72, 0x63, 0x7c, 0x60, 0x5f, 0xec, 0xe4, 0x7f, 0x85, 0x6c, 0x1e, + 0xe4, 0x30, 0xbb, 0xac, 0xf1, 0x03, 0x4c, 0x8b, 0xb0, 0x57, 0x42, 0xd7, 0xe6, 0x5e, 0x3a, 0xfd, + 0xa1, 0x65, 0xf0, 0xed, 0xc1, 0xa8, 0x19, 0xa2, 0xd4, 0x38, 0x77, 0x5b, 0xc8, 0xe6, 0xbf, 0xec, + 0x5f, 0x5e, 0x12, 0x46, 0x9a, 0x5c, 0x52, 0x8b, 0xb4, 0x37, 0xee, 0xd7, 0xeb, 0xa8, 0x6a, 0x35, + 0x57, 0x74, 0xfe, 0x19, 0x00, 0x00, 0xff, 0xff, 0xde, 0x54, 0xd1, 0xb6, 0xae, 0x02, 0x00, 0x00, } diff --git a/examples/examplepb/stream.pb.gw.go b/examples/examplepb/stream.pb.gw.go index f5bd60cea06..c6fcebe55ab 100644 --- a/examples/examplepb/stream.pb.gw.go +++ b/examples/examplepb/stream.pb.gw.go @@ -17,6 +17,7 @@ import ( "github.com/gengo/grpc-gateway/runtime" "github.com/gengo/grpc-gateway/utilities" "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes/empty" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -70,7 +71,7 @@ func request_StreamService_BulkCreate_0(ctx context.Context, marshaler runtime.M } func request_StreamService_List_0(ctx context.Context, marshaler runtime.Marshaler, client StreamServiceClient, req *http.Request, pathParams map[string]string) (StreamService_ListClient, runtime.ServerMetadata, error) { - var protoReq EmptyMessage + var protoReq empty.Empty var metadata runtime.ServerMetadata stream, err := client.List(ctx, &protoReq) diff --git a/examples/examplepb/stream.proto b/examples/examplepb/stream.proto index 989bbf01480..dbf5ac4633d 100644 --- a/examples/examplepb/stream.proto +++ b/examples/examplepb/stream.proto @@ -3,18 +3,19 @@ option go_package = "examplepb"; package gengo.grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; +import "google/protobuf/empty.proto"; import "examples/examplepb/a_bit_of_everything.proto"; import "examples/sub/message.proto"; // Defines some more operations to be added to ABitOfEverythingService service StreamService { - rpc BulkCreate(stream ABitOfEverything) returns (EmptyMessage) { + rpc BulkCreate(stream ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything/bulk" body: "*" }; } - rpc List(EmptyMessage) returns (stream ABitOfEverything) { + rpc List(google.protobuf.Empty) returns (stream ABitOfEverything) { option (google.api.http) = { get: "/v1/example/a_bit_of_everything" }; diff --git a/examples/integration_test.go b/examples/integration_test.go index 659eec0acd0..60599ba714d 100644 --- a/examples/integration_test.go +++ b/examples/integration_test.go @@ -18,6 +18,7 @@ import ( "github.com/gengo/grpc-gateway/runtime" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes/empty" "golang.org/x/net/context" "google.golang.org/grpc/codes" ) @@ -363,7 +364,7 @@ func testABEBulkCreate(t *testing.T) { t.Logf("%s", buf) } - var msg gw.EmptyMessage + var msg empty.Empty if err := jsonpb.UnmarshalString(string(buf), &msg); err != nil { t.Errorf("jsonpb.UnmarshalString(%s, &msg) failed with %v; want success", buf, err) return diff --git a/examples/server/a_bit_of_everything.go b/examples/server/a_bit_of_everything.go index 5027e01e77d..64ae39c6387 100644 --- a/examples/server/a_bit_of_everything.go +++ b/examples/server/a_bit_of_everything.go @@ -9,6 +9,7 @@ import ( sub "github.com/gengo/grpc-gateway/examples/sub" sub2 "github.com/gengo/grpc-gateway/examples/sub2" "github.com/golang/glog" + "github.com/golang/protobuf/ptypes/empty" "github.com/rogpeppe/fastuuid" "golang.org/x/net/context" "google.golang.org/grpc" @@ -87,7 +88,7 @@ func (s *_ABitOfEverythingServer) BulkCreate(stream examples.StreamService_BulkC "foo": "foo2", "bar": "bar2", })) - return stream.SendAndClose(new(examples.EmptyMessage)) + return stream.SendAndClose(new(empty.Empty)) } func (s *_ABitOfEverythingServer) Lookup(ctx context.Context, msg *sub2.IdMessage) (*examples.ABitOfEverything, error) { @@ -113,7 +114,7 @@ func (s *_ABitOfEverythingServer) Lookup(ctx context.Context, msg *sub2.IdMessag return nil, grpc.Errorf(codes.NotFound, "not found") } -func (s *_ABitOfEverythingServer) List(_ *examples.EmptyMessage, stream examples.StreamService_ListServer) error { +func (s *_ABitOfEverythingServer) List(_ *empty.Empty, stream examples.StreamService_ListServer) error { s.m.Lock() defer s.m.Unlock() @@ -143,7 +144,7 @@ func (s *_ABitOfEverythingServer) List(_ *examples.EmptyMessage, stream examples return nil } -func (s *_ABitOfEverythingServer) Update(ctx context.Context, msg *examples.ABitOfEverything) (*examples.EmptyMessage, error) { +func (s *_ABitOfEverythingServer) Update(ctx context.Context, msg *examples.ABitOfEverything) (*empty.Empty, error) { s.m.Lock() defer s.m.Unlock() @@ -153,10 +154,10 @@ func (s *_ABitOfEverythingServer) Update(ctx context.Context, msg *examples.ABit } else { return nil, grpc.Errorf(codes.NotFound, "not found") } - return new(examples.EmptyMessage), nil + return new(empty.Empty), nil } -func (s *_ABitOfEverythingServer) Delete(ctx context.Context, msg *sub2.IdMessage) (*examples.EmptyMessage, error) { +func (s *_ABitOfEverythingServer) Delete(ctx context.Context, msg *sub2.IdMessage) (*empty.Empty, error) { s.m.Lock() defer s.m.Unlock() @@ -166,7 +167,7 @@ func (s *_ABitOfEverythingServer) Delete(ctx context.Context, msg *sub2.IdMessag } else { return nil, grpc.Errorf(codes.NotFound, "not found") } - return new(examples.EmptyMessage), nil + return new(empty.Empty), nil } func (s *_ABitOfEverythingServer) Echo(ctx context.Context, msg *sub.StringMessage) (*sub.StringMessage, error) { @@ -220,7 +221,7 @@ func (s *_ABitOfEverythingServer) DeepPathEcho(ctx context.Context, msg *example return msg, nil } -func (s *_ABitOfEverythingServer) Timeout(ctx context.Context, msg *examples.EmptyMessage) (*examples.EmptyMessage, error) { +func (s *_ABitOfEverythingServer) Timeout(ctx context.Context, msg *empty.Empty) (*empty.Empty, error) { select { case <-ctx.Done(): return nil, ctx.Err()