basic_test.proto 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. syntax = "proto3";
  2. package basic_test;
  3. import "google/protobuf/wrappers.proto";
  4. import "google/protobuf/timestamp.proto";
  5. import "google/protobuf/duration.proto";
  6. import "google/protobuf/struct.proto";
  7. message Foo {
  8. Bar bar = 1;
  9. repeated Baz baz = 2;
  10. }
  11. message Bar {
  12. string msg = 1;
  13. }
  14. message Baz {
  15. string msg = 1;
  16. }
  17. message TestMessage {
  18. int32 optional_int32 = 1;
  19. int64 optional_int64 = 2;
  20. uint32 optional_uint32 = 3;
  21. uint64 optional_uint64 = 4;
  22. bool optional_bool = 5;
  23. float optional_float = 6;
  24. double optional_double = 7;
  25. string optional_string = 8;
  26. bytes optional_bytes = 9;
  27. TestMessage2 optional_msg = 10;
  28. TestEnum optional_enum = 11;
  29. repeated int32 repeated_int32 = 12;
  30. repeated int64 repeated_int64 = 13;
  31. repeated uint32 repeated_uint32 = 14;
  32. repeated uint64 repeated_uint64 = 15;
  33. repeated bool repeated_bool = 16;
  34. repeated float repeated_float = 17;
  35. repeated double repeated_double = 18;
  36. repeated string repeated_string = 19;
  37. repeated bytes repeated_bytes = 20;
  38. repeated TestMessage2 repeated_msg = 21;
  39. repeated TestEnum repeated_enum = 22;
  40. }
  41. message TestMessage2 {
  42. int32 foo = 1;
  43. }
  44. enum TestEnum {
  45. Default = 0;
  46. A = 1;
  47. B = 2;
  48. C = 3;
  49. }
  50. message TestEmbeddedMessageParent {
  51. TestEmbeddedMessageChild child_msg = 1;
  52. int32 number = 2;
  53. repeated TestEmbeddedMessageChild repeated_msg = 3;
  54. repeated int32 repeated_number = 4;
  55. }
  56. message TestEmbeddedMessageChild {
  57. TestMessage sub_child = 1;
  58. }
  59. message Recursive1 {
  60. Recursive2 foo = 1;
  61. }
  62. message Recursive2 {
  63. Recursive1 foo = 1;
  64. }
  65. message MapMessage {
  66. map<string, int32> map_string_int32 = 1;
  67. map<string, TestMessage2> map_string_msg = 2;
  68. map<string, TestEnum> map_string_enum = 3;
  69. }
  70. message MapMessageWireEquiv {
  71. repeated MapMessageWireEquiv_entry1 map_string_int32 = 1;
  72. repeated MapMessageWireEquiv_entry2 map_string_msg = 2;
  73. }
  74. message MapMessageWireEquiv_entry1 {
  75. string key = 1;
  76. int32 value = 2;
  77. }
  78. message MapMessageWireEquiv_entry2 {
  79. string key = 1;
  80. TestMessage2 value = 2;
  81. }
  82. message OneofMessage {
  83. oneof my_oneof {
  84. string a = 1;
  85. int32 b = 2;
  86. TestMessage2 c = 3;
  87. TestEnum d = 4;
  88. }
  89. }
  90. message Outer {
  91. map<int32, Inner> items = 1;
  92. }
  93. message Inner {
  94. }
  95. message Wrapper {
  96. google.protobuf.DoubleValue double = 1;
  97. google.protobuf.FloatValue float = 2;
  98. google.protobuf.Int32Value int32 = 3;
  99. google.protobuf.Int64Value int64 = 4;
  100. google.protobuf.UInt32Value uint32 = 5;
  101. google.protobuf.UInt64Value uint64 = 6;
  102. google.protobuf.BoolValue bool = 7;
  103. google.protobuf.StringValue string = 8;
  104. google.protobuf.BytesValue bytes = 9;
  105. string real_string = 100;
  106. oneof a_oneof {
  107. string string_in_oneof = 10;
  108. }
  109. // Repeated wrappers don't make sense, but we still need to make sure they
  110. // work and don't crash.
  111. repeated google.protobuf.DoubleValue repeated_double = 11;
  112. repeated google.protobuf.FloatValue repeated_float = 12;
  113. repeated google.protobuf.Int32Value repeated_int32 = 13;
  114. repeated google.protobuf.Int64Value repeated_int64 = 14;
  115. repeated google.protobuf.UInt32Value repeated_uint32 = 15;
  116. repeated google.protobuf.UInt64Value repeated_uint64 = 16;
  117. repeated google.protobuf.BoolValue repeated_bool = 17;
  118. repeated google.protobuf.StringValue repeated_string = 18;
  119. repeated google.protobuf.BytesValue repeated_bytes = 19;
  120. // Wrappers as map keys don't make sense, but we still need to make sure they
  121. // work and don't crash.
  122. map<int32, google.protobuf.DoubleValue> map_double = 21;
  123. map<int32, google.protobuf.FloatValue> map_float = 22;
  124. map<int32, google.protobuf.Int32Value> map_int32 = 23;
  125. map<int32, google.protobuf.Int64Value> map_int64 = 24;
  126. map<int32, google.protobuf.UInt32Value> map_uint32 = 25;
  127. map<int32, google.protobuf.UInt64Value> map_uint64 = 26;
  128. map<int32, google.protobuf.BoolValue> map_bool = 27;
  129. map<int32, google.protobuf.StringValue> map_string = 28;
  130. map<int32, google.protobuf.BytesValue> map_bytes = 29;
  131. // Wrappers in oneofs don't make sense, but we still need to make sure they
  132. // work and don't crash.
  133. oneof wrapper_oneof {
  134. google.protobuf.DoubleValue oneof_double = 31;
  135. google.protobuf.FloatValue oneof_float = 32;
  136. google.protobuf.Int32Value oneof_int32 = 33;
  137. google.protobuf.Int64Value oneof_int64 = 34;
  138. google.protobuf.UInt32Value oneof_uint32 = 35;
  139. google.protobuf.UInt64Value oneof_uint64 = 36;
  140. google.protobuf.BoolValue oneof_bool = 37;
  141. google.protobuf.StringValue oneof_string = 38;
  142. google.protobuf.BytesValue oneof_bytes = 39;
  143. string oneof_plain_string = 101;
  144. }
  145. }
  146. message TimeMessage {
  147. google.protobuf.Timestamp timestamp = 1;
  148. google.protobuf.Duration duration = 2;
  149. }
  150. message Enumer {
  151. TestEnum optional_enum = 1;
  152. repeated TestEnum repeated_enum = 2;
  153. string a_const = 3;
  154. oneof a_oneof {
  155. string str = 10;
  156. TestEnum const = 11;
  157. }
  158. }
  159. message MyRepeatedStruct {
  160. repeated MyStruct structs = 1;
  161. }
  162. message MyStruct {
  163. string string = 1;
  164. google.protobuf.Struct struct = 2;
  165. }