diff --git a/examples/proto/examplepb/wrappers.pb.go b/examples/proto/examplepb/wrappers.pb.go index f3caeaf4e6b..fb44ca7aba9 100644 --- a/examples/proto/examplepb/wrappers.pb.go +++ b/examples/proto/examplepb/wrappers.pb.go @@ -32,6 +32,9 @@ type Wrappers struct { 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"` + Uint32Value *wrappers.UInt32Value `protobuf:"bytes,7,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` + Uint64Value *wrappers.UInt64Value `protobuf:"bytes,8,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` + BytesValue *wrappers.BytesValue `protobuf:"bytes,9,opt,name=bytes_value,json=bytesValue,proto3" json:"bytes_value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -41,7 +44,7 @@ func (m *Wrappers) Reset() { *m = Wrappers{} } func (m *Wrappers) String() string { return proto.CompactTextString(m) } func (*Wrappers) ProtoMessage() {} func (*Wrappers) Descriptor() ([]byte, []int) { - return fileDescriptor_wrappers_c39e75a579a3cddc, []int{0} + return fileDescriptor_wrappers_5850bd48b0187754, []int{0} } func (m *Wrappers) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Wrappers.Unmarshal(m, b) @@ -103,6 +106,27 @@ func (m *Wrappers) GetBoolValue() *wrappers.BoolValue { return nil } +func (m *Wrappers) GetUint32Value() *wrappers.UInt32Value { + if m != nil { + return m.Uint32Value + } + return nil +} + +func (m *Wrappers) GetUint64Value() *wrappers.UInt64Value { + if m != nil { + return m.Uint64Value + } + return nil +} + +func (m *Wrappers) GetBytesValue() *wrappers.BytesValue { + if m != nil { + return m.BytesValue + } + return nil +} + func init() { proto.RegisterType((*Wrappers)(nil), "grpc.gateway.examples.examplepb.Wrappers") } @@ -180,30 +204,33 @@ var _WrappersService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("examples/proto/examplepb/wrappers.proto", fileDescriptor_wrappers_c39e75a579a3cddc) -} - -var fileDescriptor_wrappers_c39e75a579a3cddc = []byte{ - // 333 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0xd2, 0xcf, 0x4a, 0x3b, 0x31, - 0x10, 0x07, 0x70, 0xb6, 0xfd, 0xfd, 0x8a, 0xcd, 0x0a, 0xc2, 0xe2, 0x41, 0xd7, 0x62, 0xa5, 0x17, - 0xff, 0x1c, 0xb2, 0xd8, 0x96, 0x82, 0x22, 0x08, 0x55, 0x04, 0xaf, 0x16, 0x14, 0xbc, 0x48, 0xd2, - 0xa6, 0x4b, 0x20, 0xee, 0x84, 0x6c, 0xda, 0xea, 0x49, 0xf4, 0x11, 0xf4, 0xd1, 0x7c, 0x05, 0x1f, - 0x44, 0x36, 0x9d, 0x6c, 0xc1, 0x52, 0xf4, 0x36, 0xb3, 0xf9, 0x7e, 0x06, 0x86, 0x1d, 0xb2, 0x2f, - 0x9e, 0xd8, 0xa3, 0x56, 0x22, 0x4f, 0xb4, 0x01, 0x0b, 0x09, 0xb6, 0x9a, 0x27, 0x33, 0xc3, 0xb4, - 0x16, 0x26, 0xa7, 0xee, 0x21, 0x6a, 0xa6, 0x46, 0x0f, 0x69, 0xca, 0xac, 0x98, 0xb1, 0x67, 0xea, - 0x15, 0x2d, 0xf3, 0x71, 0x23, 0x05, 0x48, 0x95, 0x48, 0x98, 0x96, 0x09, 0xcb, 0x32, 0xb0, 0xcc, - 0x4a, 0xc8, 0x90, 0xc7, 0xbb, 0xf8, 0xea, 0x3a, 0x3e, 0x19, 0xff, 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, - 0x1d, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xa4, 0x0c, 0xe1, 0xb6, 0x02, 0x00, 0x00, + proto.RegisterFile("examples/proto/examplepb/wrappers.proto", fileDescriptor_wrappers_5850bd48b0187754) +} + +var fileDescriptor_wrappers_5850bd48b0187754 = []byte{ + // 381 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xdf, 0x4a, 0xf3, 0x30, + 0x18, 0xc6, 0xe9, 0xbe, 0x7d, 0x73, 0x4b, 0x05, 0xa1, 0x78, 0xa0, 0x75, 0x38, 0xd9, 0x89, 0x7f, + 0x0e, 0x52, 0xdc, 0xc6, 0x40, 0x11, 0x84, 0x29, 0x82, 0xa7, 0x0e, 0x15, 0x3c, 0x91, 0x64, 0xcb, + 0x4a, 0xa1, 0x36, 0x25, 0x4d, 0x37, 0x77, 0x24, 0x78, 0x09, 0x7a, 0x45, 0x5e, 0x83, 0xb7, 0xe0, + 0x85, 0x48, 0xb2, 0x37, 0xd9, 0x74, 0x54, 0x3d, 0x7b, 0xde, 0xe6, 0xf9, 0x3d, 0xe1, 0x7d, 0x48, + 0xd1, 0x2e, 0x7b, 0x24, 0x0f, 0x69, 0xcc, 0xb2, 0x20, 0x15, 0x5c, 0xf2, 0x00, 0xc6, 0x94, 0x06, + 0x13, 0x41, 0xd2, 0x94, 0x89, 0x0c, 0xeb, 0x03, 0xaf, 0x11, 0x8a, 0x74, 0x80, 0x43, 0x22, 0xd9, + 0x84, 0x4c, 0xb1, 0xa1, 0xb0, 0xf5, 0xfb, 0xf5, 0x90, 0xf3, 0x30, 0x66, 0x01, 0x49, 0xa3, 0x80, + 0x24, 0x09, 0x97, 0x44, 0x46, 0x3c, 0x01, 0xdc, 0xdf, 0x86, 0x53, 0x3d, 0xd1, 0x7c, 0xf4, 0x2d, + 0xbe, 0xf9, 0x56, 0x46, 0xd5, 0x5b, 0xf8, 0xe4, 0x9d, 0xa2, 0xd5, 0x4c, 0x8a, 0x28, 0x09, 0xef, + 0xc7, 0x24, 0xce, 0xd9, 0x86, 0xb3, 0xe3, 0xec, 0xb9, 0xad, 0x3a, 0x9e, 0x65, 0x60, 0x93, 0x81, + 0xfb, 0xda, 0x74, 0xa3, 0x3c, 0x57, 0x6e, 0x36, 0x1f, 0xbc, 0x13, 0xe4, 0x46, 0x89, 0x6c, 0xb7, + 0x80, 0x2f, 0x69, 0x7e, 0x6b, 0x89, 0xbf, 0x54, 0x9e, 0x19, 0x8e, 0x22, 0xab, 0x81, 0xee, 0x76, + 0x80, 0xfe, 0x57, 0x4c, 0x77, 0x3b, 0x73, 0x1a, 0xb4, 0xa2, 0x47, 0x31, 0x27, 0x12, 0xe8, 0x72, + 0x01, 0x7d, 0xa1, 0x3c, 0x40, 0x8f, 0xac, 0x56, 0xab, 0x0f, 0x79, 0x4e, 0x63, 0x06, 0xf8, 0xff, + 0x82, 0xd5, 0xcf, 0xb5, 0x09, 0x56, 0x1f, 0xce, 0x07, 0xef, 0x08, 0x21, 0xca, 0x79, 0x0c, 0x78, + 0x45, 0xe3, 0xfe, 0x12, 0xde, 0xe3, 0x3c, 0x9e, 0xc1, 0x35, 0x6a, 0xa4, 0xba, 0x3b, 0x5f, 0xac, + 0x6d, 0xa5, 0xe0, 0xee, 0xeb, 0x85, 0xde, 0xdc, 0x7c, 0xa1, 0x38, 0x08, 0xb0, 0xcd, 0x55, 0x7f, + 0x08, 0x30, 0xd5, 0xb9, 0xf9, 0xd7, 0xee, 0xe8, 0x54, 0xb2, 0x0c, 0xf8, 0x5a, 0x41, 0x77, 0x3d, + 0xe5, 0x81, 0xee, 0xa8, 0xd5, 0xad, 0x17, 0x07, 0xad, 0x99, 0x37, 0xd4, 0x67, 0x62, 0x1c, 0x0d, + 0x98, 0xf7, 0x84, 0x2a, 0x67, 0x82, 0x11, 0xc9, 0xbc, 0x7d, 0xfc, 0xcb, 0x0b, 0xc6, 0x86, 0xf5, + 0xff, 0x6e, 0x6d, 0x36, 0x9e, 0xdf, 0x3f, 0x5e, 0x4b, 0x9b, 0xcd, 0xf5, 0x60, 0x7c, 0x68, 0x7e, + 0x1e, 0xfb, 0xb6, 0x8f, 0x9d, 0x83, 0x9e, 0x7b, 0x57, 0xb3, 0x18, 0xad, 0xe8, 0x15, 0xda, 0x9f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xc7, 0xe3, 0xe9, 0x76, 0x03, 0x00, 0x00, } diff --git a/examples/proto/examplepb/wrappers.proto b/examples/proto/examplepb/wrappers.proto index 094b0a4c662..b232a37fc83 100644 --- a/examples/proto/examplepb/wrappers.proto +++ b/examples/proto/examplepb/wrappers.proto @@ -12,6 +12,9 @@ message Wrappers { google.protobuf.FloatValue float_value = 4; google.protobuf.DoubleValue double_value = 5; google.protobuf.BoolValue bool_value = 6; + google.protobuf.UInt32Value uint32_value = 7; + google.protobuf.UInt64Value uint64_value = 8; + google.protobuf.BytesValue bytes_value = 9; } service WrappersService { diff --git a/examples/proto/examplepb/wrappers.swagger.json b/examples/proto/examplepb/wrappers.swagger.json index 37c6144aed1..f30c5d4f0a6 100644 --- a/examples/proto/examplepb/wrappers.swagger.json +++ b/examples/proto/examplepb/wrappers.swagger.json @@ -54,7 +54,7 @@ "format": "int32" }, "int64_value": { - "type": "integer", + "type": "string", "format": "int64" }, "float_value": { @@ -68,6 +68,18 @@ "bool_value": { "type": "boolean", "format": "boolean" + }, + "uint32_value": { + "type": "integer", + "format": "int64" + }, + "uint64_value": { + "type": "string", + "format": "uint64" + }, + "bytes_value": { + "type": "string", + "format": "byte" } } } diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index f12ea38f724..3489736abd3 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -26,14 +26,26 @@ var wktSchemas = map[string]schemaCore{ ".google.protobuf.StringValue": schemaCore{ Type: "string", }, + ".google.protobuf.BytesValue": schemaCore{ + Type: "string", + Format: "byte", + }, ".google.protobuf.Int32Value": schemaCore{ Type: "integer", Format: "int32", }, - ".google.protobuf.Int64Value": schemaCore{ + ".google.protobuf.UInt32Value": schemaCore{ Type: "integer", Format: "int64", }, + ".google.protobuf.Int64Value": schemaCore{ + Type: "string", + Format: "int64", + }, + ".google.protobuf.UInt64Value": schemaCore{ + Type: "string", + Format: "uint64", + }, ".google.protobuf.FloatValue": schemaCore{ Type: "number", Format: "float", @@ -201,10 +213,16 @@ func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, continue case ".google.protobuf.StringValue": continue + case ".google.protobuf.BytesValue": + continue case ".google.protobuf.Int32Value": continue + case ".google.protobuf.UInt32Value": + continue case ".google.protobuf.Int64Value": continue + case ".google.protobuf.UInt64Value": + continue case ".google.protobuf.FloatValue": continue case ".google.protobuf.DoubleValue": diff --git a/protoc-gen-swagger/genswagger/template_test.go b/protoc-gen-swagger/genswagger/template_test.go index 115391ee352..f0ecd1e370d 100644 --- a/protoc-gen-swagger/genswagger/template_test.go +++ b/protoc-gen-swagger/genswagger/template_test.go @@ -836,6 +836,118 @@ func TestSchemaOfField(t *testing.T) { }, }, }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.BytesValue"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "string", + Format: "bytes", + }, + }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.Int32Value"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "integer", + Format: "int32", + }, + }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.UInt32Value"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "integer", + Format: "int64", + }, + }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.Int64Value"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "string", + Format: "int64", + }, + }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.UInt64Value"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "string", + Format: "uint64", + }, + }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.FloatValue"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "number", + Format: "float", + }, + }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.DoubleValue"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "number", + Format: "double", + }, + }, + { + field: &descriptor.Field{ + FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{ + Name: proto.String("wrapped_field"), + TypeName: proto.String(".google.protobuf.BoolValue"), + Type: protodescriptor.FieldDescriptorProto_TYPE_MESSAGE.Enum(), + }, + }, + refs: make(refMap), + expected: schemaCore{ + Type: "boolean", + Format: "boolean", + }, + }, { field: &descriptor.Field{ FieldDescriptorProto: &protodescriptor.FieldDescriptorProto{