From b6e267b008d5cc73935aa65fbceb9a7657450b8a Mon Sep 17 00:00:00 2001 From: Travis Cline Date: Fri, 18 Nov 2016 16:46:32 -0800 Subject: [PATCH 1/2] regenerate examples --- examples/examplepb/a_bit_of_everything.pb.go | 147 ++++++++++++++++++ examples/examplepb/echo_service.pb.go | 7 + examples/examplepb/flow_combination.pb.go | 42 +++++ examples/sub2/message.pb.go | 7 + runtime/internal/stream_chunk.pb.go | 28 ++++ .../googleapis/google/api/annotations.pb.go | 1 + third_party/googleapis/google/api/http.pb.go | 21 +++ 7 files changed, 253 insertions(+) diff --git a/examples/examplepb/a_bit_of_everything.pb.go b/examples/examplepb/a_bit_of_everything.pb.go index 4a3548496ee..d8e32353aec 100644 --- a/examples/examplepb/a_bit_of_everything.pb.go +++ b/examples/examplepb/a_bit_of_everything.pb.go @@ -140,6 +140,13 @@ func (m *ABitOfEverything) GetSingleNested() *ABitOfEverything_Nested { return nil } +func (m *ABitOfEverything) GetUuid() string { + if m != nil { + return m.Uuid + } + return "" +} + func (m *ABitOfEverything) GetNested() []*ABitOfEverything_Nested { if m != nil { return m.Nested @@ -147,6 +154,118 @@ func (m *ABitOfEverything) GetNested() []*ABitOfEverything_Nested { return nil } +func (m *ABitOfEverything) GetFloatValue() float32 { + if m != nil { + return m.FloatValue + } + return 0 +} + +func (m *ABitOfEverything) GetDoubleValue() float64 { + if m != nil { + return m.DoubleValue + } + return 0 +} + +func (m *ABitOfEverything) GetInt64Value() int64 { + if m != nil { + return m.Int64Value + } + return 0 +} + +func (m *ABitOfEverything) GetUint64Value() uint64 { + if m != nil { + return m.Uint64Value + } + return 0 +} + +func (m *ABitOfEverything) GetInt32Value() int32 { + if m != nil { + return m.Int32Value + } + return 0 +} + +func (m *ABitOfEverything) GetFixed64Value() uint64 { + if m != nil { + return m.Fixed64Value + } + return 0 +} + +func (m *ABitOfEverything) GetFixed32Value() uint32 { + if m != nil { + return m.Fixed32Value + } + return 0 +} + +func (m *ABitOfEverything) GetBoolValue() bool { + if m != nil { + return m.BoolValue + } + return false +} + +func (m *ABitOfEverything) GetStringValue() string { + if m != nil { + return m.StringValue + } + return "" +} + +func (m *ABitOfEverything) GetUint32Value() uint32 { + if m != nil { + return m.Uint32Value + } + return 0 +} + +func (m *ABitOfEverything) GetEnumValue() NumericEnum { + if m != nil { + return m.EnumValue + } + return NumericEnum_ZERO +} + +func (m *ABitOfEverything) GetSfixed32Value() int32 { + if m != nil { + return m.Sfixed32Value + } + return 0 +} + +func (m *ABitOfEverything) GetSfixed64Value() int64 { + if m != nil { + return m.Sfixed64Value + } + return 0 +} + +func (m *ABitOfEverything) GetSint32Value() int32 { + if m != nil { + return m.Sint32Value + } + return 0 +} + +func (m *ABitOfEverything) GetSint64Value() int64 { + if m != nil { + return m.Sint64Value + } + return 0 +} + +func (m *ABitOfEverything) GetRepeatedStringValue() []string { + if m != nil { + return m.RepeatedStringValue + } + return nil +} + func (m *ABitOfEverything) GetOneofEmpty() *google_protobuf1.Empty { if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofEmpty); ok { return x.OneofEmpty @@ -182,6 +301,13 @@ func (m *ABitOfEverything) GetMappedNestedValue() map[string]*ABitOfEverything_N return nil } +func (m *ABitOfEverything) GetNonConventionalNameValue() string { + if m != nil { + return m.NonConventionalNameValue + } + return "" +} + func (m *ABitOfEverything) GetTimestampValue() *google_protobuf2.Timestamp { if m != nil { return m.TimestampValue @@ -272,6 +398,27 @@ func (m *ABitOfEverything_Nested) String() string { return proto.Comp func (*ABitOfEverything_Nested) ProtoMessage() {} func (*ABitOfEverything_Nested) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0, 0} } +func (m *ABitOfEverything_Nested) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ABitOfEverything_Nested) GetAmount() uint32 { + if m != nil { + return m.Amount + } + return 0 +} + +func (m *ABitOfEverything_Nested) GetOk() ABitOfEverything_Nested_DeepEnum { + if m != nil { + return m.Ok + } + return ABitOfEverything_Nested_FALSE +} + func init() { proto.RegisterType((*ABitOfEverything)(nil), "grpc.gateway.examples.examplepb.ABitOfEverything") proto.RegisterType((*ABitOfEverything_Nested)(nil), "grpc.gateway.examples.examplepb.ABitOfEverything.Nested") diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index 756fe4c8d98..a7e19fdd932 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -59,6 +59,13 @@ func (m *SimpleMessage) String() string { return proto.CompactTextStr func (*SimpleMessage) ProtoMessage() {} func (*SimpleMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *SimpleMessage) GetId() string { + if m != nil { + return m.Id + } + return "" +} + func init() { proto.RegisterType((*SimpleMessage)(nil), "grpc.gateway.examples.examplepb.SimpleMessage") } diff --git a/examples/examplepb/flow_combination.pb.go b/examples/examplepb/flow_combination.pb.go index f6620070863..bd6dde41f4f 100644 --- a/examples/examplepb/flow_combination.pb.go +++ b/examples/examplepb/flow_combination.pb.go @@ -38,6 +38,27 @@ func (m *NonEmptyProto) String() string { return proto.CompactTextStr func (*NonEmptyProto) ProtoMessage() {} func (*NonEmptyProto) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} } +func (m *NonEmptyProto) GetA() string { + if m != nil { + return m.A + } + return "" +} + +func (m *NonEmptyProto) GetB() string { + if m != nil { + return m.B + } + return "" +} + +func (m *NonEmptyProto) GetC() string { + if m != nil { + return m.C + } + return "" +} + type UnaryProto struct { Str string `protobuf:"bytes,1,opt,name=str" json:"str,omitempty"` } @@ -47,6 +68,13 @@ func (m *UnaryProto) String() string { return proto.CompactTextString func (*UnaryProto) ProtoMessage() {} func (*UnaryProto) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{2} } +func (m *UnaryProto) GetStr() string { + if m != nil { + return m.Str + } + return "" +} + 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"` @@ -65,6 +93,20 @@ func (m *NestedProto) GetA() *UnaryProto { return nil } +func (m *NestedProto) GetB() string { + if m != nil { + return m.B + } + return "" +} + +func (m *NestedProto) GetC() string { + if m != nil { + return m.C + } + return "" +} + type SingleNestedProto struct { A *UnaryProto `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` } diff --git a/examples/sub2/message.pb.go b/examples/sub2/message.pb.go index 37d6ee759fb..dada72d4557 100644 --- a/examples/sub2/message.pb.go +++ b/examples/sub2/message.pb.go @@ -37,6 +37,13 @@ func (m *IdMessage) String() string { return proto.CompactTextString( func (*IdMessage) ProtoMessage() {} func (*IdMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *IdMessage) GetUuid() string { + if m != nil { + return m.Uuid + } + return "" +} + func init() { proto.RegisterType((*IdMessage)(nil), "sub2.IdMessage") } diff --git a/runtime/internal/stream_chunk.pb.go b/runtime/internal/stream_chunk.pb.go index 6f837cfd5d9..e2486eb8eec 100644 --- a/runtime/internal/stream_chunk.pb.go +++ b/runtime/internal/stream_chunk.pb.go @@ -42,6 +42,34 @@ func (m *StreamError) String() string { return proto.CompactTextStrin func (*StreamError) ProtoMessage() {} func (*StreamError) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *StreamError) GetGrpcCode() int32 { + if m != nil { + return m.GrpcCode + } + return 0 +} + +func (m *StreamError) GetHttpCode() int32 { + if m != nil { + return m.HttpCode + } + return 0 +} + +func (m *StreamError) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func (m *StreamError) GetHttpStatus() string { + if m != nil { + return m.HttpStatus + } + return "" +} + func init() { proto.RegisterType((*StreamError)(nil), "grpc.gateway.runtime.StreamError") } diff --git a/third_party/googleapis/google/api/annotations.pb.go b/third_party/googleapis/google/api/annotations.pb.go index 2409a86c4bf..98366b55059 100644 --- a/third_party/googleapis/google/api/annotations.pb.go +++ b/third_party/googleapis/google/api/annotations.pb.go @@ -37,6 +37,7 @@ var E_Http = &proto.ExtensionDesc{ Field: 72295728, Name: "google.api.http", Tag: "bytes,72295728,opt,name=http", + Filename: "google/api/annotations.proto", } func init() { diff --git a/third_party/googleapis/google/api/http.pb.go b/third_party/googleapis/google/api/http.pb.go index c572235923c..82e742cf031 100644 --- a/third_party/googleapis/google/api/http.pb.go +++ b/third_party/googleapis/google/api/http.pb.go @@ -180,6 +180,13 @@ func (m *HttpRule) GetCustom() *CustomHttpPattern { return nil } +func (m *HttpRule) GetBody() string { + if m != nil { + return m.Body + } + return "" +} + func (m *HttpRule) GetAdditionalBindings() []*HttpRule { if m != nil { return m.AdditionalBindings @@ -330,6 +337,20 @@ func (m *CustomHttpPattern) String() string { return proto.CompactTex func (*CustomHttpPattern) ProtoMessage() {} func (*CustomHttpPattern) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} } +func (m *CustomHttpPattern) GetKind() string { + if m != nil { + return m.Kind + } + return "" +} + +func (m *CustomHttpPattern) GetPath() string { + if m != nil { + return m.Path + } + return "" +} + func init() { proto.RegisterType((*HttpRule)(nil), "google.api.HttpRule") proto.RegisterType((*CustomHttpPattern)(nil), "google.api.CustomHttpPattern") From c56093eaf900293c5fe738704cc896e720feeec4 Mon Sep 17 00:00:00 2001 From: Travis Cline Date: Fri, 18 Nov 2016 16:53:01 -0800 Subject: [PATCH 2/2] make lint happy --- protoc-gen-swagger/genswagger/template.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index a8431d29e1c..b81c4c05635 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -386,7 +386,7 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re }, } } else { - lastField := b.Body.FieldPath[len(b.Body.FieldPath) - 1] + lastField := b.Body.FieldPath[len(b.Body.FieldPath)-1] schema = schemaOfField(lastField.Target, reg) } @@ -399,7 +399,7 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re Description: desc, In: "body", Required: true, - Schema: &schema, + Schema: &schema, }) } @@ -565,7 +565,7 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er return nil } - return fmt.Errorf("No description nor summary property.") + return fmt.Errorf("no description nor summary property") } func protoComments(reg *descriptor.Registry, file *descriptor.File, outers []string, typeName string, typeIndex int32, fieldPaths ...int32) string { @@ -693,15 +693,15 @@ func isProtoPathMatches(paths []int32, outerPaths []int32, typeName string, type func protoPathIndex(descriptorType reflect.Type, what string) int32 { field, ok := descriptorType.Elem().FieldByName(what) if !ok { - panic(fmt.Errorf("Could not find protobuf descriptor type id for %s.", what)) + panic(fmt.Errorf("could not find protobuf descriptor type id for %s", what)) } pbtag := field.Tag.Get("protobuf") if pbtag == "" { - panic(fmt.Errorf("No Go tag 'protobuf' on protobuf descriptor for %s.", what)) + panic(fmt.Errorf("no Go tag 'protobuf' on protobuf descriptor for %s", what)) } path, err := strconv.Atoi(strings.Split(pbtag, ",")[1]) if err != nil { - panic(fmt.Errorf("Protobuf descriptor id for %s cannot be converted to a number: %s", what, err.Error())) + panic(fmt.Errorf("protobuf descriptor id for %s cannot be converted to a number: %s", what, err.Error())) } return int32(path)