basic_test.proto 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. import "test_import_proto2.proto";
  8. message Foo {
  9. Bar bar = 1;
  10. repeated Baz baz = 2;
  11. }
  12. message Bar {
  13. string msg = 1;
  14. }
  15. message Baz {
  16. string msg = 1;
  17. }
  18. message TestMessage {
  19. optional int32 optional_int32 = 1;
  20. optional int64 optional_int64 = 2;
  21. optional uint32 optional_uint32 = 3;
  22. optional uint64 optional_uint64 = 4;
  23. optional bool optional_bool = 5;
  24. optional float optional_float = 6;
  25. optional double optional_double = 7;
  26. optional string optional_string = 8;
  27. optional bytes optional_bytes = 9;
  28. optional TestMessage2 optional_msg = 10;
  29. optional TestEnum optional_enum = 11;
  30. optional foo_bar.proto2.TestImportedMessage optional_proto2_submessage = 24;
  31. repeated int32 repeated_int32 = 12;
  32. repeated int64 repeated_int64 = 13;
  33. repeated uint32 repeated_uint32 = 14;
  34. repeated uint64 repeated_uint64 = 15;
  35. repeated bool repeated_bool = 16;
  36. repeated float repeated_float = 17;
  37. repeated double repeated_double = 18;
  38. repeated string repeated_string = 19;
  39. repeated bytes repeated_bytes = 20;
  40. repeated TestMessage2 repeated_msg = 21;
  41. repeated TestEnum repeated_enum = 22;
  42. optional TestSingularFields optional_msg2 = 23;
  43. }
  44. message TestSingularFields {
  45. int32 singular_int32 = 1;
  46. int64 singular_int64 = 2;
  47. uint32 singular_uint32 = 3;
  48. uint64 singular_uint64 = 4;
  49. bool singular_bool = 5;
  50. float singular_float = 6;
  51. double singular_double = 7;
  52. string singular_string = 8;
  53. bytes singular_bytes = 9;
  54. TestMessage2 singular_msg = 10;
  55. TestEnum singular_enum = 11;
  56. }
  57. message TestMessage2 {
  58. optional int32 foo = 1;
  59. }
  60. enum TestEnum {
  61. Default = 0;
  62. A = 1;
  63. B = 2;
  64. C = 3;
  65. }
  66. message TestEmbeddedMessageParent {
  67. TestEmbeddedMessageChild child_msg = 1;
  68. int32 number = 2;
  69. repeated TestEmbeddedMessageChild repeated_msg = 3;
  70. repeated int32 repeated_number = 4;
  71. }
  72. message TestEmbeddedMessageChild {
  73. TestMessage sub_child = 1;
  74. }
  75. message Recursive1 {
  76. Recursive2 foo = 1;
  77. }
  78. message Recursive2 {
  79. Recursive1 foo = 1;
  80. }
  81. message MapMessage {
  82. map<string, int32> map_string_int32 = 1;
  83. map<string, TestMessage2> map_string_msg = 2;
  84. map<string, TestEnum> map_string_enum = 3;
  85. }
  86. message MapMessageWireEquiv {
  87. repeated MapMessageWireEquiv_entry1 map_string_int32 = 1;
  88. repeated MapMessageWireEquiv_entry2 map_string_msg = 2;
  89. }
  90. message MapMessageWireEquiv_entry1 {
  91. string key = 1;
  92. int32 value = 2;
  93. }
  94. message MapMessageWireEquiv_entry2 {
  95. string key = 1;
  96. TestMessage2 value = 2;
  97. }
  98. message OneofMessage {
  99. oneof my_oneof {
  100. string a = 1;
  101. int32 b = 2;
  102. TestMessage2 c = 3;
  103. TestEnum d = 4;
  104. }
  105. }
  106. message Outer {
  107. map<int32, Inner> items = 1;
  108. }
  109. message Inner {
  110. }
  111. message Wrapper {
  112. google.protobuf.DoubleValue double = 1;
  113. google.protobuf.FloatValue float = 2;
  114. google.protobuf.Int32Value int32 = 3;
  115. google.protobuf.Int64Value int64 = 4;
  116. google.protobuf.UInt32Value uint32 = 5;
  117. google.protobuf.UInt64Value uint64 = 6;
  118. google.protobuf.BoolValue bool = 7;
  119. google.protobuf.StringValue string = 8;
  120. google.protobuf.BytesValue bytes = 9;
  121. string real_string = 100;
  122. oneof a_oneof {
  123. string string_in_oneof = 10;
  124. }
  125. // Repeated wrappers don't make sense, but we still need to make sure they
  126. // work and don't crash.
  127. repeated google.protobuf.DoubleValue repeated_double = 11;
  128. repeated google.protobuf.FloatValue repeated_float = 12;
  129. repeated google.protobuf.Int32Value repeated_int32 = 13;
  130. repeated google.protobuf.Int64Value repeated_int64 = 14;
  131. repeated google.protobuf.UInt32Value repeated_uint32 = 15;
  132. repeated google.protobuf.UInt64Value repeated_uint64 = 16;
  133. repeated google.protobuf.BoolValue repeated_bool = 17;
  134. repeated google.protobuf.StringValue repeated_string = 18;
  135. repeated google.protobuf.BytesValue repeated_bytes = 19;
  136. // Wrappers as map keys don't make sense, but we still need to make sure they
  137. // work and don't crash.
  138. map<int32, google.protobuf.DoubleValue> map_double = 21;
  139. map<int32, google.protobuf.FloatValue> map_float = 22;
  140. map<int32, google.protobuf.Int32Value> map_int32 = 23;
  141. map<int32, google.protobuf.Int64Value> map_int64 = 24;
  142. map<int32, google.protobuf.UInt32Value> map_uint32 = 25;
  143. map<int32, google.protobuf.UInt64Value> map_uint64 = 26;
  144. map<int32, google.protobuf.BoolValue> map_bool = 27;
  145. map<int32, google.protobuf.StringValue> map_string = 28;
  146. map<int32, google.protobuf.BytesValue> map_bytes = 29;
  147. // Wrappers in oneofs don't make sense, but we still need to make sure they
  148. // work and don't crash.
  149. oneof wrapper_oneof {
  150. google.protobuf.DoubleValue oneof_double = 31;
  151. google.protobuf.FloatValue oneof_float = 32;
  152. google.protobuf.Int32Value oneof_int32 = 33;
  153. google.protobuf.Int64Value oneof_int64 = 34;
  154. google.protobuf.UInt32Value oneof_uint32 = 35;
  155. google.protobuf.UInt64Value oneof_uint64 = 36;
  156. google.protobuf.BoolValue oneof_bool = 37;
  157. google.protobuf.StringValue oneof_string = 38;
  158. google.protobuf.BytesValue oneof_bytes = 39;
  159. string oneof_plain_string = 101;
  160. }
  161. }
  162. message TimeMessage {
  163. google.protobuf.Timestamp timestamp = 1;
  164. google.protobuf.Duration duration = 2;
  165. }
  166. message Enumer {
  167. TestEnum optional_enum = 1;
  168. repeated TestEnum repeated_enum = 2;
  169. string a_const = 3;
  170. oneof a_oneof {
  171. string str = 10;
  172. TestEnum const = 11;
  173. }
  174. }
  175. message MyRepeatedStruct {
  176. repeated MyStruct structs = 1;
  177. }
  178. message MyStruct {
  179. string string = 1;
  180. google.protobuf.Struct struct = 2;
  181. }
  182. message WithJsonName {
  183. optional int32 foo_bar = 1 [json_name="jsonFooBar"];
  184. repeated WithJsonName baz = 2 [json_name="jsonBaz"];
  185. }
  186. message HelloRequest {
  187. optional uint32 id = 1;
  188. optional uint32 random_name_a0 = 2;
  189. optional uint32 random_name_a1 = 3;
  190. optional uint32 random_name_a2 = 4;
  191. optional uint32 random_name_a3 = 5;
  192. optional uint32 random_name_a4 = 6;
  193. optional uint32 random_name_a5 = 7;
  194. optional uint32 random_name_a6 = 8;
  195. optional uint32 random_name_a7 = 9;
  196. optional uint32 random_name_a8 = 10;
  197. optional uint32 random_name_a9 = 11;
  198. optional uint32 random_name_b0 = 12;
  199. optional uint32 random_name_b1 = 13;
  200. optional uint32 random_name_b2 = 14;
  201. optional uint32 random_name_b3 = 15;
  202. optional uint32 random_name_b4 = 16;
  203. optional uint32 random_name_b5 = 17;
  204. optional uint32 random_name_b6 = 18;
  205. optional uint32 random_name_b7 = 19;
  206. optional uint32 random_name_b8 = 20;
  207. optional uint32 random_name_b9 = 21;
  208. optional uint32 random_name_c0 = 22;
  209. optional uint32 random_name_c1 = 23;
  210. optional uint32 random_name_c2 = 24;
  211. optional uint32 random_name_c3 = 25;
  212. optional uint32 random_name_c4 = 26;
  213. optional uint32 random_name_c5 = 27;
  214. optional uint32 random_name_c6 = 28;
  215. optional uint32 random_name_c7 = 29;
  216. optional uint32 random_name_c8 = 30;
  217. optional uint32 random_name_c9 = 31;
  218. optional string version = 32;
  219. }