From 7f2e9507539a786703a38d25ad801b04b0dd833b Mon Sep 17 00:00:00 2001 From: Maxime Fischer Date: Sat, 18 Feb 2017 14:40:32 +0000 Subject: [PATCH] Update ABE example to include a method with no bindings that uses an imported package which is not used by any other method. --- examples/clients/abe/ProtobufDuration.go | 10 + examples/examplepb/a_bit_of_everything.pb.go | 181 +++++++++--------- .../examplepb/a_bit_of_everything.pb.gw.go | 1 + examples/examplepb/a_bit_of_everything.proto | 3 +- .../a_bit_of_everything.swagger.json | 16 ++ examples/server/a_bit_of_everything.go | 3 +- 6 files changed, 123 insertions(+), 91 deletions(-) create mode 100644 examples/clients/abe/ProtobufDuration.go diff --git a/examples/clients/abe/ProtobufDuration.go b/examples/clients/abe/ProtobufDuration.go new file mode 100644 index 00000000000..837f298bd91 --- /dev/null +++ b/examples/clients/abe/ProtobufDuration.go @@ -0,0 +1,10 @@ +package abe + +import ( +) + +type ProtobufDuration struct { + Seconds string `json:"seconds,omitempty"` + Nanos int32 `json:"nanos,omitempty"` + +} diff --git a/examples/examplepb/a_bit_of_everything.pb.go b/examples/examplepb/a_bit_of_everything.pb.go index 964d9ca7d39..79af189db91 100644 --- a/examples/examplepb/a_bit_of_everything.pb.go +++ b/examples/examplepb/a_bit_of_everything.pb.go @@ -9,9 +9,10 @@ import fmt "fmt" import math "math" import _ "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api" import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" +import google_protobuf2 "github.com/golang/protobuf/ptypes/duration" import grpc_gateway_examples_sub "github.com/grpc-ecosystem/grpc-gateway/examples/sub" import sub2 "github.com/grpc-ecosystem/grpc-gateway/examples/sub2" -import google_protobuf2 "github.com/golang/protobuf/ptypes/timestamp" +import google_protobuf3 "github.com/golang/protobuf/ptypes/timestamp" import ( context "golang.org/x/net/context" @@ -104,7 +105,7 @@ type ABitOfEverything struct { MappedStringValue map[string]string `protobuf:"bytes,23,rep,name=mapped_string_value,json=mappedStringValue" json:"mapped_string_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` MappedNestedValue map[string]*ABitOfEverything_Nested `protobuf:"bytes,24,rep,name=mapped_nested_value,json=mappedNestedValue" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` NonConventionalNameValue string `protobuf:"bytes,26,opt,name=nonConventionalNameValue" json:"nonConventionalNameValue,omitempty"` - TimestampValue *google_protobuf2.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"` + TimestampValue *google_protobuf3.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"` // repeated enum value. it is comma-separated in query RepeatedEnumValue []NumericEnum `protobuf:"varint,28,rep,packed,name=repeated_enum_value,json=repeatedEnumValue,enum=grpc.gateway.examples.examplepb.NumericEnum" json:"repeated_enum_value,omitempty"` } @@ -310,7 +311,7 @@ func (m *ABitOfEverything) GetNonConventionalNameValue() string { return "" } -func (m *ABitOfEverything) GetTimestampValue() *google_protobuf2.Timestamp { +func (m *ABitOfEverything) GetTimestampValue() *google_protobuf3.Timestamp { if m != nil { return m.TimestampValue } @@ -454,7 +455,7 @@ type ABitOfEverythingServiceClient interface { GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Echo(ctx context.Context, in *grpc_gateway_examples_sub.StringMessage, opts ...grpc.CallOption) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) - NoBindings(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + NoBindings(ctx context.Context, in *google_protobuf2.Duration, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Timeout(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) } @@ -538,7 +539,7 @@ func (c *aBitOfEverythingServiceClient) DeepPathEcho(ctx context.Context, in *AB return out, nil } -func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { +func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *google_protobuf2.Duration, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/NoBindings", in, out, c.cc, opts...) if err != nil { @@ -567,7 +568,7 @@ type ABitOfEverythingServiceServer interface { GetQuery(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) Echo(context.Context, *grpc_gateway_examples_sub.StringMessage) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(context.Context, *ABitOfEverything) (*ABitOfEverything, error) - NoBindings(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) + NoBindings(context.Context, *google_protobuf2.Duration) (*google_protobuf1.Empty, error) Timeout(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) } @@ -720,7 +721,7 @@ func _ABitOfEverythingService_DeepPathEcho_Handler(srv interface{}, ctx context. } func _ABitOfEverythingService_NoBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(google_protobuf1.Empty) + in := new(google_protobuf2.Duration) if err := dec(in); err != nil { return nil, err } @@ -732,7 +733,7 @@ func _ABitOfEverythingService_NoBindings_Handler(srv interface{}, ctx context.Co FullMethod: "/grpc.gateway.examples.examplepb.ABitOfEverythingService/NoBindings", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, req.(*google_protobuf1.Empty)) + return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, req.(*google_protobuf2.Duration)) } return interceptor(ctx, in, info, handler) } @@ -871,85 +872,87 @@ var _AnotherServiceWithNoBindings_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/a_bit_of_everything.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 1278 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x6e, 0xdb, 0x46, - 0x13, 0xf7, 0x4a, 0xb6, 0x2c, 0x8d, 0x24, 0x5b, 0x5e, 0x27, 0x8e, 0xa2, 0xe4, 0x83, 0xf8, 0x29, - 0x6d, 0x41, 0xb8, 0x01, 0x89, 0x28, 0x41, 0x91, 0x18, 0x68, 0x03, 0x2b, 0x51, 0x9b, 0xa2, 0x89, - 0x92, 0xd0, 0x49, 0x0a, 0x18, 0x49, 0x05, 0x4a, 0x5a, 0x49, 0x84, 0x45, 0x2e, 0x4b, 0x2e, 0x55, - 0x0b, 0xaa, 0x7a, 0xe8, 0xa1, 0x97, 0x1e, 0x7b, 0xcf, 0xa5, 0x40, 0xd1, 0x4b, 0x8f, 0x3d, 0xb7, - 0xef, 0xd0, 0x57, 0x68, 0xdf, 0xa3, 0xe0, 0x2e, 0x49, 0x53, 0xb2, 0x05, 0xf9, 0x4f, 0x91, 0x1b, - 0x77, 0x67, 0xe6, 0x37, 0xbf, 0x99, 0xd9, 0x99, 0x5d, 0xc2, 0x4d, 0x72, 0xa8, 0x9b, 0xf6, 0x80, - 0xb8, 0x6a, 0xf0, 0x61, 0xb7, 0x54, 0xbd, 0xd9, 0x32, 0x58, 0x93, 0x76, 0x9b, 0x64, 0x48, 0x9c, - 0x11, 0xeb, 0x1b, 0x56, 0x4f, 0xb1, 0x1d, 0xca, 0x28, 0x2e, 0xf7, 0x1c, 0xbb, 0xad, 0xf4, 0x74, - 0x46, 0xbe, 0xd1, 0x47, 0x4a, 0x68, 0xaa, 0x44, 0xa6, 0xa5, 0xeb, 0x3d, 0x4a, 0x7b, 0x03, 0xa2, - 0xea, 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b, 0xa4, 0x24, 0x24, 0x2f, 0x6b, 0x59, 0x2f, - 0xa6, 0x22, 0x30, 0x6e, 0x57, 0x03, 0x8d, 0x55, 0x09, 0xc9, 0x2b, 0x1c, 0xe3, 0x76, 0x55, 0x28, - 0xdc, 0x80, 0x7c, 0xd7, 0x38, 0x24, 0x9d, 0x08, 0x24, 0x2d, 0x21, 0x39, 0xa5, 0xe5, 0x82, 0xcd, - 0x69, 0xa5, 0x08, 0x27, 0x23, 0x21, 0x79, 0x35, 0x50, 0x0a, 0x91, 0xfe, 0x07, 0xd0, 0xa2, 0x74, - 0x10, 0x68, 0x80, 0x84, 0xe4, 0xb4, 0x96, 0xf1, 0x77, 0x22, 0xb2, 0x2e, 0x73, 0x0c, 0xab, 0x17, - 0x28, 0x64, 0x79, 0xfe, 0xb3, 0x62, 0x6f, 0x2a, 0x9e, 0xc8, 0x4b, 0x5e, 0x42, 0x72, 0x5e, 0xc4, - 0x13, 0x3a, 0xf9, 0x02, 0x80, 0x58, 0x9e, 0x19, 0x28, 0xac, 0x49, 0x48, 0x5e, 0xab, 0xde, 0x5c, - 0x58, 0xad, 0x86, 0x67, 0x12, 0xc7, 0x68, 0xd7, 0x2d, 0xcf, 0xd4, 0x32, 0xbe, 0xbd, 0x00, 0x7b, - 0x1f, 0xd6, 0xdc, 0xe9, 0xb8, 0xd6, 0x25, 0x24, 0xaf, 0x6b, 0x79, 0x77, 0x2a, 0xb0, 0x48, 0x2d, - 0xca, 0x51, 0x41, 0x42, 0x72, 0x21, 0x54, 0x8b, 0x55, 0xc3, 0x8d, 0xb3, 0xdf, 0x90, 0x90, 0xbc, - 0xa1, 0x65, 0xdd, 0x18, 0xfb, 0x40, 0x25, 0xc2, 0xc1, 0x12, 0x92, 0xb1, 0x50, 0x09, 0x51, 0xaa, - 0x70, 0xd9, 0x21, 0x36, 0xd1, 0x19, 0xe9, 0x34, 0xa7, 0xf2, 0xb5, 0x29, 0x25, 0xe5, 0x8c, 0xb6, - 0x19, 0x0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0xec, 0x26, 0x95, - 0xdf, 0x12, 0xdf, 0xff, 0xf5, 0xf7, 0x4f, 0x89, 0x5f, 0x12, 0x95, 0x9f, 0x13, 0xea, 0xf0, 0x56, - 0xf8, 0xb6, 0x3a, 0xe9, 0x65, 0xa5, 0x8e, 0x63, 0x37, 0xf8, 0x44, 0x1d, 0xc7, 0xaf, 0xeb, 0x89, - 0x3a, 0x8e, 0xcd, 0xf1, 0x89, 0xea, 0x12, 0x5b, 0x77, 0x74, 0x46, 0x1d, 0x75, 0xec, 0x4d, 0x09, - 0xc6, 0xb1, 0x1b, 0x61, 0xa2, 0x8e, 0xa7, 0xae, 0x91, 0x70, 0x1d, 0x93, 0x1f, 0x5d, 0xa0, 0x13, - 0x75, 0x1c, 0x1f, 0x87, 0x1f, 0xbb, 0xcc, 0xb1, 0x1d, 0xd2, 0x35, 0x0e, 0xd5, 0xed, 0x89, 0x70, - 0x12, 0x33, 0x73, 0x67, 0x71, 0xdc, 0x59, 0x47, 0xee, 0x8c, 0xc1, 0x34, 0xc9, 0x79, 0xb3, 0x66, - 0x82, 0xdf, 0x22, 0x00, 0x51, 0xa0, 0x1a, 0xed, 0x8c, 0xde, 0x51, 0x91, 0xb6, 0x79, 0x8d, 0xde, - 0xab, 0x94, 0x17, 0x54, 0x68, 0x07, 0x6d, 0xe3, 0x6f, 0x21, 0xf5, 0x98, 0xd2, 0x03, 0xcf, 0xc6, - 0xeb, 0x8a, 0xff, 0x04, 0x55, 0x3e, 0xef, 0x3c, 0x11, 0x8f, 0xd0, 0xf3, 0x78, 0x56, 0xb8, 0x67, - 0x19, 0x7f, 0xb0, 0xf0, 0x6c, 0xf8, 0xef, 0xc6, 0x09, 0xfe, 0x01, 0x41, 0xea, 0xa5, 0xdd, 0x39, - 0xe7, 0xf9, 0x9d, 0x73, 0x45, 0x57, 0x6e, 0x71, 0x16, 0x1f, 0x96, 0x4e, 0xc9, 0xc2, 0x4f, 0x83, - 0x0e, 0xa9, 0x87, 0x64, 0x40, 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, 0xda, 0x4a, 0x71, 0xf1, 0xed, - 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe6, 0xf7, 0xb8, 0x85, 0xa6, 0x0f, 0x00, 0x00, + // 1297 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xd8, 0x89, 0x13, 0x3f, 0xc7, 0x89, 0x33, 0x69, 0x53, 0xd7, 0x2d, 0x64, 0x71, 0x01, + 0xad, 0x42, 0xb5, 0xab, 0xba, 0x15, 0x6a, 0x23, 0x41, 0x95, 0x34, 0x86, 0x22, 0xda, 0xb4, 0xdd, + 0xfe, 0x41, 0x8a, 0x5a, 0xac, 0xb5, 0x3d, 0xb6, 0x57, 0xf1, 0xee, 0x2c, 0xbb, 0xb3, 0x26, 0x96, + 0x31, 0x07, 0x0e, 0x5c, 0x38, 0x72, 0xef, 0x05, 0x09, 0x71, 0xe1, 0xc8, 0x19, 0xbe, 0x03, 0x5f, + 0x81, 0x03, 0x1f, 0x03, 0xed, 0xcc, 0xec, 0x76, 0xd7, 0x89, 0xe5, 0x26, 0x45, 0xbd, 0xed, 0xcc, + 0x7b, 0xef, 0xf7, 0x7b, 0x7f, 0xe6, 0xbd, 0x99, 0x85, 0xab, 0xe4, 0xc8, 0xb4, 0xdd, 0x3e, 0xf1, + 0x75, 0xf9, 0xe1, 0x36, 0x75, 0xb3, 0xd1, 0xb4, 0x58, 0x83, 0x76, 0x1a, 0x64, 0x40, 0xbc, 0x21, + 0xeb, 0x59, 0x4e, 0x57, 0x73, 0x3d, 0xca, 0x28, 0xde, 0xec, 0x7a, 0x6e, 0x4b, 0xeb, 0x9a, 0x8c, + 0x7c, 0x6b, 0x0e, 0xb5, 0xc8, 0x54, 0x8b, 0x4d, 0x2b, 0x97, 0xbb, 0x94, 0x76, 0xfb, 0x44, 0x37, + 0x5d, 0x4b, 0x37, 0x1d, 0x87, 0x32, 0x93, 0x59, 0xd4, 0xf1, 0x85, 0x79, 0xe5, 0x92, 0x94, 0xf2, + 0x55, 0x33, 0xe8, 0xe8, 0xc4, 0x76, 0xd9, 0x50, 0x0a, 0xdf, 0x9d, 0x14, 0xb6, 0x03, 0x8f, 0x5b, + 0x4b, 0x79, 0x25, 0xf6, 0xd4, 0x0f, 0x9a, 0xba, 0x4d, 0x7c, 0xdf, 0xec, 0x92, 0x08, 0x38, 0x29, + 0xab, 0x4d, 0x08, 0x37, 0x27, 0x81, 0x99, 0x65, 0x13, 0x9f, 0x99, 0xb6, 0x2b, 0x14, 0xaa, 0x7f, + 0xad, 0x42, 0x69, 0x67, 0xd7, 0x62, 0x0f, 0x3a, 0xf5, 0x38, 0x60, 0xfc, 0x02, 0x8a, 0xbe, 0xe5, + 0x74, 0xfb, 0xa4, 0xe1, 0x10, 0x9f, 0x91, 0x76, 0xf9, 0xa2, 0x82, 0xd4, 0x42, 0xed, 0xa6, 0x36, + 0x23, 0x05, 0xda, 0x24, 0x92, 0xb6, 0xcf, 0xed, 0x8d, 0x65, 0x01, 0x27, 0x56, 0x18, 0xc3, 0x7c, + 0x10, 0x58, 0xed, 0x32, 0x52, 0x90, 0x9a, 0x37, 0xf8, 0x37, 0x7e, 0x08, 0x39, 0xc9, 0x95, 0x51, + 0xb2, 0x6f, 0xc4, 0x25, 0x71, 0xf0, 0x26, 0x14, 0x3a, 0x7d, 0x6a, 0xb2, 0xc6, 0xc0, 0xec, 0x07, + 0xa4, 0x9c, 0x55, 0x90, 0x9a, 0x31, 0x80, 0x6f, 0x3d, 0x0b, 0x77, 0xf0, 0x7b, 0xb0, 0xdc, 0xa6, + 0x41, 0xb3, 0x4f, 0xa4, 0xc6, 0xbc, 0x82, 0x54, 0x64, 0x14, 0xc4, 0x9e, 0x50, 0xd9, 0x84, 0x82, + 0xe5, 0xb0, 0x8f, 0x6f, 0x48, 0x8d, 0x05, 0x05, 0xa9, 0x59, 0x03, 0xf8, 0x56, 0x8c, 0x11, 0x24, + 0x35, 0x72, 0x0a, 0x52, 0xe7, 0x8d, 0x42, 0x90, 0x50, 0x11, 0x18, 0xd7, 0x6b, 0x52, 0x63, 0x51, + 0x41, 0xea, 0x02, 0xc7, 0xb8, 0x5e, 0x13, 0x0a, 0x57, 0xa0, 0xd8, 0xb1, 0x8e, 0x48, 0x3b, 0x06, + 0x59, 0x52, 0x90, 0x9a, 0x33, 0x96, 0xe5, 0x66, 0x5a, 0x29, 0xc6, 0xc9, 0x2b, 0x48, 0x5d, 0x94, + 0x4a, 0x11, 0xd2, 0x3b, 0x00, 0x4d, 0x4a, 0xfb, 0x52, 0x03, 0x14, 0xa4, 0x2e, 0x19, 0xf9, 0x70, + 0x27, 0x76, 0xd6, 0x67, 0x9e, 0xe5, 0x74, 0xa5, 0x42, 0x81, 0xe7, 0xbf, 0x20, 0xf6, 0x52, 0xf1, + 0xc4, 0x2c, 0x45, 0x05, 0xa9, 0x45, 0x11, 0x4f, 0x44, 0xf2, 0x25, 0x00, 0x71, 0x02, 0x5b, 0x2a, + 0xac, 0x28, 0x48, 0x5d, 0xa9, 0x5d, 0x9d, 0x59, 0xad, 0xfd, 0xc0, 0x26, 0x9e, 0xd5, 0xaa, 0x3b, + 0x81, 0x6d, 0xe4, 0x43, 0x7b, 0x01, 0xf6, 0x01, 0xac, 0xf8, 0xe9, 0xb8, 0x56, 0x15, 0xa4, 0xae, + 0x1a, 0x45, 0x3f, 0x15, 0x58, 0xac, 0x16, 0xe7, 0xa8, 0xa4, 0x20, 0xb5, 0x14, 0xa9, 0x25, 0xaa, + 0xe1, 0x27, 0xbd, 0x5f, 0x53, 0x90, 0xba, 0x66, 0x14, 0xfc, 0x84, 0xf7, 0x52, 0x25, 0xc6, 0xc1, + 0x0a, 0x52, 0xb1, 0x50, 0x89, 0x50, 0x6a, 0x70, 0xde, 0x23, 0x2e, 0x31, 0x19, 0x69, 0x37, 0x52, + 0xf9, 0x5a, 0x57,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xca, 0x7a, 0xc4, 0x93, 0x17, 0xcc, 0x57, 0x16, 0xeb, + 0x25, 0x9c, 0xfd, 0x34, 0xe5, 0xfa, 0x69, 0xa9, 0xe7, 0x76, 0x0b, 0x07, 0xf9, 0x38, 0xb3, 0xcd, + 0x1c, 0x17, 0x5f, 0xff, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xab, 0xe5, 0x92, 0x0d, 0xc9, 0x0f, 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 f8f3eabd0fc..7cef435ca11 100644 --- a/examples/examplepb/a_bit_of_everything.pb.gw.go +++ b/examples/examplepb/a_bit_of_everything.pb.gw.go @@ -14,6 +14,7 @@ import ( "net/http" "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes/duration" "github.com/golang/protobuf/ptypes/empty" "github.com/grpc-ecosystem/grpc-gateway/examples/sub" "github.com/grpc-ecosystem/grpc-gateway/examples/sub2" diff --git a/examples/examplepb/a_bit_of_everything.proto b/examples/examplepb/a_bit_of_everything.proto index 7ff55a4a0c6..91e561e06a8 100644 --- a/examples/examplepb/a_bit_of_everything.proto +++ b/examples/examplepb/a_bit_of_everything.proto @@ -4,6 +4,7 @@ package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; +import "google/protobuf/duration.proto"; import "examples/sub/message.proto"; import "examples/sub2/message.proto"; import "google/protobuf/timestamp.proto"; @@ -123,7 +124,7 @@ service ABitOfEverythingService { body: "*" }; } - rpc NoBindings(google.protobuf.Empty) returns (google.protobuf.Empty) {} + rpc NoBindings(google.protobuf.Duration) returns (google.protobuf.Empty) {} 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 7f73c164dec..780d0d9c426 100644 --- a/examples/examplepb/a_bit_of_everything.swagger.json +++ b/examples/examplepb/a_bit_of_everything.swagger.json @@ -718,6 +718,22 @@ "default": "ZERO", "description": "NumericEnum is one or zero.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1" }, + "protobufDuration": { + "type": "object", + "properties": { + "seconds": { + "type": "string", + "format": "int64", + "description": "Signed seconds of the span of time. Must be from -315,576,000,000\nto +315,576,000,000 inclusive." + }, + "nanos": { + "type": "integer", + "format": "int32", + "description": "Signed fractions of a second at nanosecond resolution of the span\nof time. Durations less than one second are represented with a 0\n`seconds` field and a positive or negative `nanos` field. For durations\nof one second or more, a non-zero value for the `nanos` field must be\nof the same sign as the `seconds` field. Must be from -999,999,999\nto +999,999,999 inclusive." + } + }, + "description": "A Duration represents a signed, fixed-length span of time represented\nas a count of seconds and fractions of seconds at nanosecond\nresolution. It is independent of any calendar and concepts like \"day\"\nor \"month\". It is related to Timestamp in that the difference between\ntwo Timestamp values is a Duration and it can be added or subtracted\nfrom a Timestamp. Range is approximately +-10,000 years.\n\nExample 1: Compute Duration from two Timestamps in pseudo code.\n\n Timestamp start = ...;\n Timestamp end = ...;\n Duration duration = ...;\n\n duration.seconds = end.seconds - start.seconds;\n duration.nanos = end.nanos - start.nanos;\n\n if (duration.seconds \u003c 0 \u0026\u0026 duration.nanos \u003e 0) {\n duration.seconds += 1;\n duration.nanos -= 1000000000;\n } else if (durations.seconds \u003e 0 \u0026\u0026 duration.nanos \u003c 0) {\n duration.seconds -= 1;\n duration.nanos += 1000000000;\n }\n\nExample 2: Compute Timestamp from Timestamp + Duration in pseudo code.\n\n Timestamp start = ...;\n Duration duration = ...;\n Timestamp end = ...;\n\n end.seconds = start.seconds + duration.seconds;\n end.nanos = start.nanos + duration.nanos;\n\n if (end.nanos \u003c 0) {\n end.seconds -= 1;\n end.nanos += 1000000000;\n } else if (end.nanos \u003e= 1000000000) {\n end.seconds += 1;\n end.nanos -= 1000000000;\n }\n\nExample 3: Compute Duration from datetime.timedelta in Python.\n\n td = datetime.timedelta(days=3, minutes=10)\n duration = Duration()\n duration.FromTimedelta(td)" + }, "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 `{}`.", diff --git a/examples/server/a_bit_of_everything.go b/examples/server/a_bit_of_everything.go index 5f48e797419..07bdcce8ea9 100644 --- a/examples/server/a_bit_of_everything.go +++ b/examples/server/a_bit_of_everything.go @@ -6,6 +6,7 @@ import ( "sync" "github.com/golang/glog" + "github.com/golang/protobuf/ptypes/duration" "github.com/golang/protobuf/ptypes/empty" examples "github.com/grpc-ecosystem/grpc-gateway/examples/examplepb" sub "github.com/grpc-ecosystem/grpc-gateway/examples/sub" @@ -234,7 +235,7 @@ func (s *_ABitOfEverythingServer) DeepPathEcho(ctx context.Context, msg *example return msg, nil } -func (s *_ABitOfEverythingServer) NoBindings(ctx context.Context, msg *empty.Empty) (*empty.Empty, error) { +func (s *_ABitOfEverythingServer) NoBindings(ctx context.Context, msg *duration.Duration) (*empty.Empty, error) { return nil, nil }