From acbd1bf87b8e94c2ce95fb5fa9e54a2bf3bd0f34 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Tue, 10 Jan 2017 11:40:48 +0100 Subject: [PATCH] Plain support of Nested Enums --- examples/flow/output/test/test_grpc_js.js | 4 ++++ examples/flow/protos/test.proto | 4 ++++ helpers.go | 5 ++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/flow/output/test/test_grpc_js.js b/examples/flow/output/test/test_grpc_js.js index db9204d..2510017 100644 --- a/examples/flow/output/test/test_grpc_js.js +++ b/examples/flow/output/test/test_grpc_js.js @@ -57,6 +57,10 @@ export type TestMessage = {| r?: Array; + u?: TestEnum; + + v?: TestNestedEnum; + TestNestedMessage?: TestNestedMessage; diff --git a/examples/flow/protos/test.proto b/examples/flow/protos/test.proto index 7458188..93ae06e 100644 --- a/examples/flow/protos/test.proto +++ b/examples/flow/protos/test.proto @@ -27,6 +27,7 @@ message TestMessage { repeated int64 p = 16; repeated float q = 17; repeated double r = 18; + message TestNestedMessage { string s = 1; int32 t = 2; @@ -35,6 +36,9 @@ message TestMessage { ELEMENT_C = 0; ELEMENT_D = 1; } + + TestEnum u = 19; + TestNestedEnum v = 20; } message TestNoStreamRequest { TestMessage message = 1; } diff --git a/helpers.go b/helpers.go index 038f3ee..0550b98 100644 --- a/helpers.go +++ b/helpers.go @@ -148,7 +148,8 @@ func jsType(f *descriptor.FieldDescriptorProto) string { } switch *f.Type { - case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + case descriptor.FieldDescriptorProto_TYPE_MESSAGE, + descriptor.FieldDescriptorProto_TYPE_ENUM: return fmt.Sprintf(template, shortType(*f.TypeName)) case descriptor.FieldDescriptorProto_TYPE_DOUBLE, descriptor.FieldDescriptorProto_TYPE_FLOAT, @@ -169,8 +170,6 @@ func jsType(f *descriptor.FieldDescriptorProto) string { return fmt.Sprintf(template, "Array") case descriptor.FieldDescriptorProto_TYPE_STRING: return fmt.Sprintf(template, "string") - case descriptor.FieldDescriptorProto_TYPE_ENUM: - return fmt.Sprintf(template, "Object") default: return fmt.Sprintf(template, "any") }