basic_test.proto 5.3 KB

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