diff --git a/examples/proto/examplepb/a_bit_of_everything.pb.go b/examples/proto/examplepb/a_bit_of_everything.pb.go index 520dae9c337..32c3d2d0b68 100644 --- a/examples/proto/examplepb/a_bit_of_everything.pb.go +++ b/examples/proto/examplepb/a_bit_of_everything.pb.go @@ -85,37 +85,37 @@ func (ABitOfEverything_Nested_DeepEnum) EnumDescriptor() ([]byte, []int) { // Intentionaly complicated message type to cover much features of Protobuf. // NEXT ID: 30 type ABitOfEverything struct { - SingleNested *ABitOfEverything_Nested `protobuf:"bytes,25,opt,name=single_nested,json=singleNested" json:"single_nested,omitempty"` - Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"` - Nested []*ABitOfEverything_Nested `protobuf:"bytes,2,rep,name=nested" json:"nested,omitempty"` - FloatValue float32 `protobuf:"fixed32,3,opt,name=float_value,json=floatValue" json:"float_value,omitempty"` - DoubleValue float64 `protobuf:"fixed64,4,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"` - Int64Value int64 `protobuf:"varint,5,opt,name=int64_value,json=int64Value" json:"int64_value,omitempty"` - Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value" json:"uint64_value,omitempty"` - Int32Value int32 `protobuf:"varint,7,opt,name=int32_value,json=int32Value" json:"int32_value,omitempty"` - Fixed64Value uint64 `protobuf:"fixed64,8,opt,name=fixed64_value,json=fixed64Value" json:"fixed64_value,omitempty"` - Fixed32Value uint32 `protobuf:"fixed32,9,opt,name=fixed32_value,json=fixed32Value" json:"fixed32_value,omitempty"` - BoolValue bool `protobuf:"varint,10,opt,name=bool_value,json=boolValue" json:"bool_value,omitempty"` - StringValue string `protobuf:"bytes,11,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` + SingleNested *ABitOfEverything_Nested `protobuf:"bytes,25,opt,name=single_nested,json=singleNested,proto3" json:"single_nested,omitempty"` + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` + Nested []*ABitOfEverything_Nested `protobuf:"bytes,2,rep,name=nested,proto3" json:"nested,omitempty"` + FloatValue float32 `protobuf:"fixed32,3,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` + DoubleValue float64 `protobuf:"fixed64,4,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` + Int64Value int64 `protobuf:"varint,5,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` + Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` + Int32Value int32 `protobuf:"varint,7,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` + Fixed64Value uint64 `protobuf:"fixed64,8,opt,name=fixed64_value,json=fixed64Value,proto3" json:"fixed64_value,omitempty"` + Fixed32Value uint32 `protobuf:"fixed32,9,opt,name=fixed32_value,json=fixed32Value,proto3" json:"fixed32_value,omitempty"` + BoolValue bool `protobuf:"varint,10,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` + StringValue string `protobuf:"bytes,11,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` BytesValue []byte `protobuf:"bytes,29,opt,name=bytes_value,json=bytesValue,proto3" json:"bytes_value,omitempty"` - Uint32Value uint32 `protobuf:"varint,13,opt,name=uint32_value,json=uint32Value" json:"uint32_value,omitempty"` - EnumValue NumericEnum `protobuf:"varint,14,opt,name=enum_value,json=enumValue,enum=grpc.gateway.examples.examplepb.NumericEnum" json:"enum_value,omitempty"` - Sfixed32Value int32 `protobuf:"fixed32,15,opt,name=sfixed32_value,json=sfixed32Value" json:"sfixed32_value,omitempty"` - Sfixed64Value int64 `protobuf:"fixed64,16,opt,name=sfixed64_value,json=sfixed64Value" json:"sfixed64_value,omitempty"` - Sint32Value int32 `protobuf:"zigzag32,17,opt,name=sint32_value,json=sint32Value" json:"sint32_value,omitempty"` - Sint64Value int64 `protobuf:"zigzag64,18,opt,name=sint64_value,json=sint64Value" json:"sint64_value,omitempty"` - RepeatedStringValue []string `protobuf:"bytes,19,rep,name=repeated_string_value,json=repeatedStringValue" json:"repeated_string_value,omitempty"` + Uint32Value uint32 `protobuf:"varint,13,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` + EnumValue NumericEnum `protobuf:"varint,14,opt,name=enum_value,json=enumValue,proto3,enum=grpc.gateway.examples.examplepb.NumericEnum" json:"enum_value,omitempty"` + Sfixed32Value int32 `protobuf:"fixed32,15,opt,name=sfixed32_value,json=sfixed32Value,proto3" json:"sfixed32_value,omitempty"` + Sfixed64Value int64 `protobuf:"fixed64,16,opt,name=sfixed64_value,json=sfixed64Value,proto3" json:"sfixed64_value,omitempty"` + Sint32Value int32 `protobuf:"zigzag32,17,opt,name=sint32_value,json=sint32Value,proto3" json:"sint32_value,omitempty"` + Sint64Value int64 `protobuf:"zigzag64,18,opt,name=sint64_value,json=sint64Value,proto3" json:"sint64_value,omitempty"` + RepeatedStringValue []string `protobuf:"bytes,19,rep,name=repeated_string_value,json=repeatedStringValue,proto3" json:"repeated_string_value,omitempty"` // Types that are valid to be assigned to OneofValue: // *ABitOfEverything_OneofEmpty // *ABitOfEverything_OneofString OneofValue isABitOfEverything_OneofValue `protobuf_oneof:"oneof_value"` - MapValue map[string]NumericEnum `protobuf:"bytes,22,rep,name=map_value,json=mapValue" json:"map_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=grpc.gateway.examples.examplepb.NumericEnum"` - 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 *timestamp.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"` + MapValue map[string]NumericEnum `protobuf:"bytes,22,rep,name=map_value,json=mapValue,proto3" json:"map_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=grpc.gateway.examples.examplepb.NumericEnum"` + MappedStringValue map[string]string `protobuf:"bytes,23,rep,name=mapped_string_value,json=mappedStringValue,proto3" json:"mapped_string_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + MappedNestedValue map[string]*ABitOfEverything_Nested `protobuf:"bytes,24,rep,name=mapped_nested_value,json=mappedNestedValue,proto3" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + NonConventionalNameValue string `protobuf:"bytes,26,opt,name=nonConventionalNameValue,proto3" json:"nonConventionalNameValue,omitempty"` + TimestampValue *timestamp.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue,proto3" 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"` + RepeatedEnumValue []NumericEnum `protobuf:"varint,28,rep,packed,name=repeated_enum_value,json=repeatedEnumValue,proto3,enum=grpc.gateway.examples.examplepb.NumericEnum" json:"repeated_enum_value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -150,10 +150,10 @@ type isABitOfEverything_OneofValue interface { } type ABitOfEverything_OneofEmpty struct { - OneofEmpty *empty.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` + OneofEmpty *empty.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,proto3,oneof"` } type ABitOfEverything_OneofString struct { - OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,oneof"` + OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,proto3,oneof"` } func (*ABitOfEverything_OneofEmpty) isABitOfEverything_OneofValue() {} @@ -435,9 +435,9 @@ func _ABitOfEverything_OneofSizer(msg proto.Message) (n int) { // Nested is nested type. type ABitOfEverything_Nested struct { // name is nested field. - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Amount uint32 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"` - Ok ABitOfEverything_Nested_DeepEnum `protobuf:"varint,3,opt,name=ok,enum=grpc.gateway.examples.examplepb.ABitOfEverything_Nested_DeepEnum" json:"ok,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Amount uint32 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` + Ok ABitOfEverything_Nested_DeepEnum `protobuf:"varint,3,opt,name=ok,proto3,enum=grpc.gateway.examples.examplepb.ABitOfEverything_Nested_DeepEnum" json:"ok,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -489,7 +489,7 @@ func (m *ABitOfEverything_Nested) GetOk() ABitOfEverything_Nested_DeepEnum { } type Body struct { - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -527,8 +527,8 @@ func (m *Body) GetName() string { } type MessageWithBody struct { - Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` - Data *Body `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Data *Body `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` diff --git a/examples/proto/examplepb/echo_service.pb.go b/examples/proto/examplepb/echo_service.pb.go index 42a70d155e9..c99f75b69cc 100644 --- a/examples/proto/examplepb/echo_service.pb.go +++ b/examples/proto/examplepb/echo_service.pb.go @@ -71,10 +71,10 @@ type isEmbedded_Mark interface { } type Embedded_Progress struct { - Progress int64 `protobuf:"varint,1,opt,name=progress,oneof"` + Progress int64 `protobuf:"varint,1,opt,name=progress,proto3,oneof"` } type Embedded_Note struct { - Note string `protobuf:"bytes,2,opt,name=note,oneof"` + Note string `protobuf:"bytes,2,opt,name=note,proto3,oneof"` } func (*Embedded_Progress) isEmbedded_Mark() {} @@ -169,13 +169,13 @@ func _Embedded_OneofSizer(msg proto.Message) (n int) { // SimpleMessage represents a simple message sent to the Echo service. type SimpleMessage struct { // Id represents the message identifier. - Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` - Num int64 `protobuf:"varint,2,opt,name=num" json:"num,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Num int64 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` // Types that are valid to be assigned to Code: // *SimpleMessage_LineNum // *SimpleMessage_Lang Code isSimpleMessage_Code `protobuf_oneof:"code"` - Status *Embedded `protobuf:"bytes,5,opt,name=status" json:"status,omitempty"` + Status *Embedded `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` // Types that are valid to be assigned to Ext: // *SimpleMessage_En // *SimpleMessage_No @@ -217,16 +217,16 @@ type isSimpleMessage_Ext interface { } type SimpleMessage_LineNum struct { - LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=lineNum,oneof"` + LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=lineNum,proto3,oneof"` } type SimpleMessage_Lang struct { - Lang string `protobuf:"bytes,4,opt,name=lang,oneof"` + Lang string `protobuf:"bytes,4,opt,name=lang,proto3,oneof"` } type SimpleMessage_En struct { - En int64 `protobuf:"varint,6,opt,name=en,oneof"` + En int64 `protobuf:"varint,6,opt,name=en,proto3,oneof"` } type SimpleMessage_No struct { - No *Embedded `protobuf:"bytes,7,opt,name=no,oneof"` + No *Embedded `protobuf:"bytes,7,opt,name=no,proto3,oneof"` } func (*SimpleMessage_LineNum) isSimpleMessage_Code() {} diff --git a/examples/proto/examplepb/flow_combination.pb.go b/examples/proto/examplepb/flow_combination.pb.go index 55be4381b5e..25e2b775e50 100644 --- a/examples/proto/examplepb/flow_combination.pb.go +++ b/examples/proto/examplepb/flow_combination.pb.go @@ -55,9 +55,9 @@ func (m *EmptyProto) XXX_DiscardUnknown() { var xxx_messageInfo_EmptyProto proto.InternalMessageInfo type NonEmptyProto struct { - A string `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` - B string `protobuf:"bytes,2,opt,name=b" json:"b,omitempty"` - C string `protobuf:"bytes,3,opt,name=c" json:"c,omitempty"` + A string `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` + B string `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"` + C string `protobuf:"bytes,3,opt,name=c,proto3" json:"c,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -109,7 +109,7 @@ func (m *NonEmptyProto) GetC() string { } type UnaryProto struct { - Str string `protobuf:"bytes,1,opt,name=str" json:"str,omitempty"` + Str string `protobuf:"bytes,1,opt,name=str,proto3" json:"str,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -147,9 +147,9 @@ func (m *UnaryProto) GetStr() string { } type NestedProto struct { - A *UnaryProto `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` - B string `protobuf:"bytes,2,opt,name=b" json:"b,omitempty"` - C string `protobuf:"bytes,3,opt,name=c" json:"c,omitempty"` + A *UnaryProto `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` + B string `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"` + C string `protobuf:"bytes,3,opt,name=c,proto3" json:"c,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -201,7 +201,7 @@ func (m *NestedProto) GetC() string { } type SingleNestedProto struct { - A *UnaryProto `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` + A *UnaryProto `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` diff --git a/examples/proto/examplepb/unannotated_echo_service.pb.go b/examples/proto/examplepb/unannotated_echo_service.pb.go index 733ab6e8162..28f0d7311d0 100644 --- a/examples/proto/examplepb/unannotated_echo_service.pb.go +++ b/examples/proto/examplepb/unannotated_echo_service.pb.go @@ -37,9 +37,9 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // UnannotatedSimpleMessage represents a simple message sent to the unannotated Echo service. type UnannotatedSimpleMessage struct { // Id represents the message identifier. - Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` - Num int64 `protobuf:"varint,2,opt,name=num" json:"num,omitempty"` - Duration *duration.Duration `protobuf:"bytes,3,opt,name=duration" json:"duration,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Num int64 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` + Duration *duration.Duration `protobuf:"bytes,3,opt,name=duration,proto3" json:"duration,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` diff --git a/examples/proto/examplepb/wrappers.pb.go b/examples/proto/examplepb/wrappers.pb.go index a5065f9d378..f3caeaf4e6b 100644 --- a/examples/proto/examplepb/wrappers.pb.go +++ b/examples/proto/examplepb/wrappers.pb.go @@ -26,12 +26,12 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type Wrappers struct { - StringValue *wrappers.StringValue `protobuf:"bytes,1,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` - Int32Value *wrappers.Int32Value `protobuf:"bytes,2,opt,name=int32_value,json=int32Value" json:"int32_value,omitempty"` - Int64Value *wrappers.Int64Value `protobuf:"bytes,3,opt,name=int64_value,json=int64Value" json:"int64_value,omitempty"` - FloatValue *wrappers.FloatValue `protobuf:"bytes,4,opt,name=float_value,json=floatValue" json:"float_value,omitempty"` - DoubleValue *wrappers.DoubleValue `protobuf:"bytes,5,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"` - BoolValue *wrappers.BoolValue `protobuf:"bytes,6,opt,name=bool_value,json=boolValue" json:"bool_value,omitempty"` + StringValue *wrappers.StringValue `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` + Int32Value *wrappers.Int32Value `protobuf:"bytes,2,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` + Int64Value *wrappers.Int64Value `protobuf:"bytes,3,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` + FloatValue *wrappers.FloatValue `protobuf:"bytes,4,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` + DoubleValue *wrappers.DoubleValue `protobuf:"bytes,5,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` + BoolValue *wrappers.BoolValue `protobuf:"bytes,6,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` diff --git a/examples/proto/sub2/message.pb.go b/examples/proto/sub2/message.pb.go index a0a812c7d0f..6819b67ae3c 100644 --- a/examples/proto/sub2/message.pb.go +++ b/examples/proto/sub2/message.pb.go @@ -19,7 +19,7 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type IdMessage struct { - Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"` + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` diff --git a/protoc-gen-swagger/options/openapiv2.pb.go b/protoc-gen-swagger/options/openapiv2.pb.go index be2342b7154..0b0f89d817f 100644 --- a/protoc-gen-swagger/options/openapiv2.pb.go +++ b/protoc-gen-swagger/options/openapiv2.pb.go @@ -190,16 +190,16 @@ func (SecurityScheme_Flow) EnumDescriptor() ([]byte, []int) { // // TODO(ivucica): document fields type Swagger struct { - Swagger string `protobuf:"bytes,1,opt,name=swagger" json:"swagger,omitempty"` - Info *Info `protobuf:"bytes,2,opt,name=info" json:"info,omitempty"` - Host string `protobuf:"bytes,3,opt,name=host" json:"host,omitempty"` - BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath" json:"base_path,omitempty"` - Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,enum=grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"` - Consumes []string `protobuf:"bytes,6,rep,name=consumes" json:"consumes,omitempty"` - Produces []string `protobuf:"bytes,7,rep,name=produces" json:"produces,omitempty"` - SecurityDefinitions *SecurityDefinitions `protobuf:"bytes,11,opt,name=security_definitions,json=securityDefinitions" json:"security_definitions,omitempty"` - Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security" json:"security,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` + Swagger string `protobuf:"bytes,1,opt,name=swagger,proto3" json:"swagger,omitempty"` + Info *Info `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` + Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` + BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath,proto3" json:"base_path,omitempty"` + Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,proto3,enum=grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"` + Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` + Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` + SecurityDefinitions *SecurityDefinitions `protobuf:"bytes,11,opt,name=security_definitions,json=securityDefinitions,proto3" json:"security_definitions,omitempty"` + Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -305,16 +305,16 @@ func (m *Swagger) GetExternalDocs() *ExternalDocumentation { // // TODO(ivucica): document fields type Operation struct { - Tags []string `protobuf:"bytes,1,rep,name=tags" json:"tags,omitempty"` - Summary string `protobuf:"bytes,2,opt,name=summary" json:"summary,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` - OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId" json:"operation_id,omitempty"` - Consumes []string `protobuf:"bytes,6,rep,name=consumes" json:"consumes,omitempty"` - Produces []string `protobuf:"bytes,7,rep,name=produces" json:"produces,omitempty"` - Schemes []string `protobuf:"bytes,10,rep,name=schemes" json:"schemes,omitempty"` - Deprecated bool `protobuf:"varint,11,opt,name=deprecated" json:"deprecated,omitempty"` - Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security" json:"security,omitempty"` + Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"` + Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` + OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId,proto3" json:"operation_id,omitempty"` + Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` + Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` + Schemes []string `protobuf:"bytes,10,rep,name=schemes,proto3" json:"schemes,omitempty"` + Deprecated bool `protobuf:"varint,11,opt,name=deprecated,proto3" json:"deprecated,omitempty"` + Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -420,11 +420,11 @@ func (m *Operation) GetSecurity() []*SecurityRequirement { // // TODO(ivucica): document fields type Info struct { - Title string `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` - TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService" json:"terms_of_service,omitempty"` - Contact *Contact `protobuf:"bytes,4,opt,name=contact" json:"contact,omitempty"` - Version string `protobuf:"bytes,6,opt,name=version" json:"version,omitempty"` + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService,proto3" json:"terms_of_service,omitempty"` + Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"` + Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -495,9 +495,9 @@ func (m *Info) GetVersion() string { // // TODO(ivucica): document fields type Contact struct { - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"` - Email string `protobuf:"bytes,3,opt,name=email" json:"email,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` + Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -555,8 +555,8 @@ func (m *Contact) GetEmail() string { // // TODO(ivucica): document fields type ExternalDocumentation struct { - Description string `protobuf:"bytes,1,opt,name=description" json:"description,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"` + Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -606,11 +606,11 @@ func (m *ExternalDocumentation) GetUrl() string { // // TODO(ivucica): document fields type Schema struct { - JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema" json:"json_schema,omitempty"` - Discriminator string `protobuf:"bytes,2,opt,name=discriminator" json:"discriminator,omitempty"` - ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly" json:"read_only,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` - Example *any.Any `protobuf:"bytes,6,opt,name=example" json:"example,omitempty"` + JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"` + Discriminator string `protobuf:"bytes,2,opt,name=discriminator,proto3" json:"discriminator,omitempty"` + ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` + Example *any.Any `protobuf:"bytes,6,opt,name=example,proto3" json:"example,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -687,26 +687,26 @@ func (m *Schema) GetExample() *any.Any { // // TODO(ivucica): document fields type JSONSchema struct { - Title string `protobuf:"bytes,5,opt,name=title" json:"title,omitempty"` - Description string `protobuf:"bytes,6,opt,name=description" json:"description,omitempty"` - Default string `protobuf:"bytes,7,opt,name=default" json:"default,omitempty"` - MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf" json:"multiple_of,omitempty"` - Maximum float64 `protobuf:"fixed64,11,opt,name=maximum" json:"maximum,omitempty"` - ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum" json:"exclusive_maximum,omitempty"` - Minimum float64 `protobuf:"fixed64,13,opt,name=minimum" json:"minimum,omitempty"` - ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum" json:"exclusive_minimum,omitempty"` - MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength" json:"max_length,omitempty"` - MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength" json:"min_length,omitempty"` - Pattern string `protobuf:"bytes,17,opt,name=pattern" json:"pattern,omitempty"` - MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems" json:"max_items,omitempty"` - MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems" json:"min_items,omitempty"` - UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems" json:"unique_items,omitempty"` - MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties" json:"max_properties,omitempty"` - MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties" json:"min_properties,omitempty"` - Required []string `protobuf:"bytes,26,rep,name=required" json:"required,omitempty"` + Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + Default string `protobuf:"bytes,7,opt,name=default,proto3" json:"default,omitempty"` + MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf,proto3" json:"multiple_of,omitempty"` + Maximum float64 `protobuf:"fixed64,11,opt,name=maximum,proto3" json:"maximum,omitempty"` + ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum,proto3" json:"exclusive_maximum,omitempty"` + Minimum float64 `protobuf:"fixed64,13,opt,name=minimum,proto3" json:"minimum,omitempty"` + ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum,proto3" json:"exclusive_minimum,omitempty"` + MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` + MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` + Pattern string `protobuf:"bytes,17,opt,name=pattern,proto3" json:"pattern,omitempty"` + MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems,proto3" json:"max_items,omitempty"` + MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems,proto3" json:"min_items,omitempty"` + UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems,proto3" json:"unique_items,omitempty"` + MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties,proto3" json:"max_properties,omitempty"` + MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties,proto3" json:"min_properties,omitempty"` + Required []string `protobuf:"bytes,26,rep,name=required,proto3" json:"required,omitempty"` // Items in 'array' must be unique. - Array []string `protobuf:"bytes,34,rep,name=array" json:"array,omitempty"` - Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,enum=grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` + Array []string `protobuf:"bytes,34,rep,name=array,proto3" json:"array,omitempty"` + Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,proto3,enum=grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -877,8 +877,8 @@ func (m *JSONSchema) GetType() []JSONSchema_JSONSchemaSimpleTypes { type Tag struct { // TODO(ivucica): Description should be extracted from comments on the proto // service object. - Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` - ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -932,7 +932,7 @@ func (m *Tag) GetExternalDocs() *ExternalDocumentation { // and only serves to provide the relevant details for each scheme. type SecurityDefinitions struct { // A single security scheme definition, mapping a "name" to the scheme it defines. - Security map[string]*SecurityScheme `protobuf:"bytes,1,rep,name=security" json:"security,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Security map[string]*SecurityScheme `protobuf:"bytes,1,rep,name=security,proto3" json:"security,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -981,36 +981,36 @@ func (m *SecurityDefinitions) GetSecurity() map[string]*SecurityScheme { type SecurityScheme struct { // Required. The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". - Type SecurityScheme_Type `protobuf:"varint,1,opt,name=type,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Type" json:"type,omitempty"` + Type SecurityScheme_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Type" json:"type,omitempty"` // A short description for security scheme. - Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // Required. The name of the header or query parameter to be used. // // Valid for apiKey. - Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // Required. The location of the API key. Valid values are "query" or "header". // // Valid for apiKey. - In SecurityScheme_In `protobuf:"varint,4,opt,name=in,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_In" json:"in,omitempty"` + In SecurityScheme_In `protobuf:"varint,4,opt,name=in,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_In" json:"in,omitempty"` // Required. The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". // // Valid for oauth2. - Flow SecurityScheme_Flow `protobuf:"varint,5,opt,name=flow,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Flow" json:"flow,omitempty"` + Flow SecurityScheme_Flow `protobuf:"varint,5,opt,name=flow,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Flow" json:"flow,omitempty"` // Required. The authorization URL to be used for this flow. This SHOULD be in // the form of a URL. // // Valid for oauth2/implicit and oauth2/accessCode. - AuthorizationUrl string `protobuf:"bytes,6,opt,name=authorization_url,json=authorizationUrl" json:"authorization_url,omitempty"` + AuthorizationUrl string `protobuf:"bytes,6,opt,name=authorization_url,json=authorizationUrl,proto3" json:"authorization_url,omitempty"` // Required. The token URL to be used for this flow. This SHOULD be in the // form of a URL. // // Valid for oauth2/password, oauth2/application and oauth2/accessCode. - TokenUrl string `protobuf:"bytes,7,opt,name=token_url,json=tokenUrl" json:"token_url,omitempty"` + TokenUrl string `protobuf:"bytes,7,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"` // Required. The available scopes for the OAuth2 security scheme. // // Valid for oauth2. - Scopes *Scopes `protobuf:"bytes,8,opt,name=scopes" json:"scopes,omitempty"` + Scopes *Scopes `protobuf:"bytes,8,opt,name=scopes,proto3" json:"scopes,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1112,7 +1112,7 @@ type SecurityRequirement struct { // the Security Definitions. If the security scheme is of type "oauth2", // then the value is a list of scope names required for the execution. // For other security scheme types, the array MUST be empty. - SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue `protobuf:"bytes,1,rep,name=security_requirement,json=securityRequirement" json:"security_requirement,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue `protobuf:"bytes,1,rep,name=security_requirement,json=securityRequirement,proto3" json:"security_requirement,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1153,7 +1153,7 @@ func (m *SecurityRequirement) GetSecurityRequirement() map[string]*SecurityRequi // scope names required for the execution. For other security scheme types, // the array MUST be empty. type SecurityRequirement_SecurityRequirementValue struct { - Scope []string `protobuf:"bytes,1,rep,name=scope" json:"scope,omitempty"` + Scope []string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1202,7 +1202,7 @@ func (m *SecurityRequirement_SecurityRequirementValue) GetScope() []string { type Scopes struct { // Maps between a name of a scope to a short description of it (as the value // of the property). - Scope map[string]string `protobuf:"bytes,1,rep,name=scope" json:"scope,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Scope map[string]string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` diff --git a/runtime/BUILD.bazel b/runtime/BUILD.bazel index e04db4f7096..9fce0447165 100644 --- a/runtime/BUILD.bazel +++ b/runtime/BUILD.bazel @@ -74,6 +74,7 @@ go_test( "@com_github_golang_protobuf//ptypes/timestamp:go_default_library", "@com_github_golang_protobuf//ptypes/wrappers:go_default_library", "@org_golang_google_genproto//protobuf/field_mask:go_default_library", + "@org_golang_google_genproto//googleapis/rpc/errdetails:go_default_library", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//codes:go_default_library", "@org_golang_google_grpc//metadata:go_default_library", diff --git a/runtime/errors.go b/runtime/errors.go index 5cfedbf790a..d112dfb7e13 100644 --- a/runtime/errors.go +++ b/runtime/errors.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/any" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" @@ -94,19 +93,9 @@ func DefaultHTTPError(ctx context.Context, mux *ServeMux, marshaler Marshaler, w } body := &errorBody{ - Error: s.Message(), - Code: int32(s.Code()), - } - - for _, detail := range s.Details() { - if det, ok := detail.(proto.Message); ok { - a, err := ptypes.MarshalAny(det) - if err != nil { - grpclog.Infof("Failed to marshal any: %v", err) - } else { - body.Details = append(body.Details, a) - } - } + Error: s.Message(), + Code: int32(s.Code()), + Details: s.Proto().GetDetails(), } buf, merr := marshaler.Marshal(body) diff --git a/runtime/errors_test.go b/runtime/errors_test.go index 2c7ecf18656..de51052893f 100644 --- a/runtime/errors_test.go +++ b/runtime/errors_test.go @@ -1,6 +1,7 @@ package runtime_test import ( + "context" "encoding/json" "fmt" "net/http" @@ -8,8 +9,8 @@ import ( "strings" "testing" - "context" "github.com/grpc-ecosystem/grpc-gateway/runtime" + "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -17,10 +18,15 @@ import ( func TestDefaultHTTPError(t *testing.T) { ctx := context.Background() + statusWithDetails, _ := status.New(codes.FailedPrecondition, "failed precondition").WithDetails( + &errdetails.PreconditionFailure{}, + ) + for _, spec := range []struct { - err error - status int - msg string + err error + status int + msg string + details string }{ { err: fmt.Errorf("example error"), @@ -32,10 +38,16 @@ func TestDefaultHTTPError(t *testing.T) { status: http.StatusNotFound, msg: "no such resource", }, + { + err: statusWithDetails.Err(), + status: http.StatusPreconditionFailed, + msg: "failed precondition", + details: "type.googleapis.com/google.rpc.PreconditionFailure", + }, } { w := httptest.NewRecorder() req, _ := http.NewRequest("", "", nil) // Pass in an empty request to match the signature - runtime.DefaultHTTPError(ctx, &runtime.ServeMux{}, &runtime.JSONBuiltin{}, w, req, spec.err) + runtime.DefaultHTTPError(ctx, &runtime.ServeMux{}, &runtime.JSONPb{}, w, req, spec.err) if got, want := w.Header().Get("Content-Type"), "application/json"; got != want { t.Errorf(`w.Header().Get("Content-Type") = %q; want %q; on spec.err=%v`, got, want, spec.err) @@ -53,5 +65,20 @@ func TestDefaultHTTPError(t *testing.T) { if got, want := body["error"].(string), spec.msg; !strings.Contains(got, want) { t.Errorf(`body["error"] = %q; want %q; on spec.err=%v`, got, want, spec.err) } + + if spec.details != "" { + details, ok := body["details"].([]interface{}) + if !ok { + t.Errorf(`body["details"] = %T; want %T`, body["details"], []interface{}{}) + continue + } + if len(details) != 1 { + t.Errorf(`len(body["details"]) = %v; want 1`, len(details)) + continue + } + if details[0].(map[string]interface{})["@type"] != spec.details { + t.Errorf(`details.@type = %s; want %s`, details[0].(map[string]interface{})["@type"], spec.details) + } + } } } diff --git a/runtime/internal/stream_chunk.pb.go b/runtime/internal/stream_chunk.pb.go index a06c722c167..f4af074808b 100644 --- a/runtime/internal/stream_chunk.pb.go +++ b/runtime/internal/stream_chunk.pb.go @@ -22,11 +22,11 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // StreamError is a response type which is returned when // streaming rpc returns an error. type StreamError struct { - GrpcCode int32 `protobuf:"varint,1,opt,name=grpc_code,json=grpcCode" json:"grpc_code,omitempty"` - HttpCode int32 `protobuf:"varint,2,opt,name=http_code,json=httpCode" json:"http_code,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` - HttpStatus string `protobuf:"bytes,4,opt,name=http_status,json=httpStatus" json:"http_status,omitempty"` - Details []*any.Any `protobuf:"bytes,5,rep,name=details" json:"details,omitempty"` + GrpcCode int32 `protobuf:"varint,1,opt,name=grpc_code,json=grpcCode,proto3" json:"grpc_code,omitempty"` + HttpCode int32 `protobuf:"varint,2,opt,name=http_code,json=httpCode,proto3" json:"http_code,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + HttpStatus string `protobuf:"bytes,4,opt,name=http_status,json=httpStatus,proto3" json:"http_status,omitempty"` + Details []*any.Any `protobuf:"bytes,5,rep,name=details,proto3" json:"details,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"`