test.proto 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // Author: mwr@google.com (Mark Rawling)
  31. syntax = "proto2";
  32. option java_package = "com.google.apps.jspb.proto";
  33. option java_multiple_files = true;
  34. import "google/protobuf/descriptor.proto";
  35. package jspb.test;
  36. message Empty {}
  37. enum OuterEnum {
  38. FOO = 1;
  39. BAR = 2;
  40. }
  41. message EnumContainer {
  42. optional OuterEnum outer_enum = 1;
  43. }
  44. message Simple1 {
  45. required string a_string = 1;
  46. repeated string a_repeated_string = 2;
  47. optional bool a_boolean = 3;
  48. }
  49. // A message that differs from Simple1 only by name
  50. message Simple2 {
  51. required string a_string = 1;
  52. repeated string a_repeated_string = 2;
  53. }
  54. message SpecialCases {
  55. required string normal = 1;
  56. // Examples of Js reserved names that are converted to pb_<name>.
  57. required string default = 2;
  58. required string function = 3;
  59. required string var = 4;
  60. }
  61. message OptionalFields {
  62. message Nested {
  63. optional int32 an_int = 1;
  64. }
  65. optional string a_string = 1;
  66. required bool a_bool = 2;
  67. optional Nested a_nested_message = 3;
  68. repeated Nested a_repeated_message = 4;
  69. repeated string a_repeated_string = 5;
  70. }
  71. message HasExtensions {
  72. optional string str1 = 1;
  73. optional string str2 = 2;
  74. optional string str3 = 3;
  75. extensions 10 to max;
  76. }
  77. message Complex {
  78. message Nested {
  79. required int32 an_int = 2;
  80. }
  81. required string a_string = 1;
  82. required bool an_out_of_order_bool = 9;
  83. optional Nested a_nested_message = 4;
  84. repeated Nested a_repeated_message = 5;
  85. repeated string a_repeated_string = 7;
  86. }
  87. message OuterMessage {
  88. // Make sure this doesn't conflict with the other Complex message.
  89. message Complex {
  90. optional int32 inner_complex_field = 1;
  91. }
  92. }
  93. message MineField {
  94. // document.cookie is a banned property in a couple of conformance check
  95. // configs at Google. Verify that having a field called cookie doesn't confuse
  96. // the compiler and break the build.
  97. optional string cookie = 1;
  98. }
  99. message IsExtension {
  100. extend HasExtensions {
  101. optional IsExtension ext_field = 100;
  102. }
  103. optional string ext1 = 1;
  104. // Extensions of proto2 Descriptor messages will be ignored.
  105. extend google.protobuf.EnumOptions {
  106. optional string simple_option = 42113038;
  107. }
  108. }
  109. message IndirectExtension {
  110. extend HasExtensions {
  111. optional Simple1 simple = 101;
  112. optional string str = 102;
  113. repeated string repeated_str = 103;
  114. repeated Simple1 repeated_simple = 104;
  115. }
  116. }
  117. extend HasExtensions {
  118. optional Simple1 simple1 = 105;
  119. }
  120. message DefaultValues {
  121. enum Enum {
  122. E1 = 13;
  123. E2 = 77;
  124. }
  125. optional string string_field = 1 [default = "default<>\'\"abc"];
  126. optional bool bool_field = 2 [default = true];
  127. optional int64 int_field = 3 [default = 11];
  128. optional Enum enum_field = 4 [default = E1];
  129. optional string empty_field = 6 [default = ""];
  130. optional bytes bytes_field = 8
  131. [default = "moo"]; // Base64 encoding is "bW9v"
  132. }
  133. message FloatingPointFields {
  134. optional float optional_float_field = 1;
  135. required float required_float_field = 2;
  136. repeated float repeated_float_field = 3;
  137. optional float default_float_field = 4 [default = 2.0];
  138. optional double optional_double_field = 5;
  139. required double required_double_field = 6;
  140. repeated double repeated_double_field = 7;
  141. optional double default_double_field = 8 [default = 2.0];
  142. }
  143. message TestClone {
  144. optional string str = 1;
  145. optional Simple1 simple1 = 3;
  146. repeated Simple1 simple2 = 5;
  147. optional bytes bytes_field = 6;
  148. optional string unused = 7;
  149. extensions 10 to max;
  150. }
  151. message TestCloneExtension {
  152. extend TestClone {
  153. optional TestCloneExtension low_ext = 11;
  154. }
  155. optional int32 f = 1;
  156. }
  157. message CloneExtension {
  158. extend TestClone {
  159. optional CloneExtension ext_field = 100;
  160. }
  161. optional string ext = 2;
  162. }
  163. message TestGroup {
  164. repeated group RepeatedGroup = 1 {
  165. required string id = 1;
  166. repeated bool some_bool = 2;
  167. }
  168. required group RequiredGroup = 2 {
  169. required string id = 1;
  170. }
  171. optional group OptionalGroup = 3 {
  172. required string id = 1;
  173. }
  174. optional string id = 4;
  175. required Simple2 required_simple = 5;
  176. optional Simple2 optional_simple = 6;
  177. }
  178. message TestGroup1 {
  179. optional TestGroup.RepeatedGroup group = 1;
  180. }
  181. message TestReservedNames {
  182. optional int32 extension = 1;
  183. extensions 10 to max;
  184. }
  185. message TestReservedNamesExtension {
  186. extend TestReservedNames {
  187. optional int32 foo = 10;
  188. }
  189. }
  190. message TestMessageWithOneof {
  191. oneof partial_oneof {
  192. string pone = 3;
  193. string pthree = 5;
  194. }
  195. oneof recursive_oneof {
  196. TestMessageWithOneof rone = 6;
  197. string rtwo = 7;
  198. }
  199. optional bool normal_field = 8;
  200. repeated string repeated_field = 9;
  201. oneof default_oneof_a {
  202. int32 aone = 10 [default = 1234];
  203. int32 atwo = 11;
  204. }
  205. oneof default_oneof_b {
  206. int32 bone = 12;
  207. int32 btwo = 13 [default = 1234];
  208. }
  209. }
  210. message TestEndsWithBytes {
  211. optional int32 value = 1;
  212. optional bytes data = 2;
  213. }
  214. // This message is for testing extension handling doesn't affect fields before
  215. // pivot. Don't add new field to this message. See b/117298778 for more detail.
  216. message TestLastFieldBeforePivot {
  217. optional int32 last_field_before_pivot = 1;
  218. extensions 100 to max;
  219. }
  220. extend TestLastFieldBeforePivot {
  221. optional int32 extend_test_last_field_before_pivot_field = 101;
  222. }
  223. message Int64Types {
  224. optional int64 int64_normal = 1 [jstype = JS_NORMAL];
  225. optional sint64 int64_string = 2 [jstype = JS_STRING];
  226. optional uint64 int64_number = 3 [jstype = JS_NUMBER];
  227. }
  228. message TestMapFieldsNoBinary {
  229. map<string, string> map_string_string = 1;
  230. map<string, int32> map_string_int32 = 2;
  231. map<string, int64> map_string_int64 = 3;
  232. map<string, bool> map_string_bool = 4;
  233. map<string, double> map_string_double = 5;
  234. map<string, MapValueEnumNoBinary> map_string_enum = 6;
  235. map<string, MapValueMessageNoBinary> map_string_msg = 7;
  236. map<int32, string> map_int32_string = 8;
  237. map<int64, string> map_int64_string = 9;
  238. map<bool, string> map_bool_string = 10;
  239. optional TestMapFieldsNoBinary test_map_fields = 11;
  240. map<string, TestMapFieldsNoBinary> map_string_testmapfields = 12;
  241. }
  242. enum MapValueEnumNoBinary {
  243. MAP_VALUE_FOO_NOBINARY = 0;
  244. MAP_VALUE_BAR_NOBINARY = 1;
  245. MAP_VALUE_BAZ_NOBINARY = 2;
  246. }
  247. message MapValueMessageNoBinary {
  248. optional int32 foo = 1;
  249. }
  250. message Deeply {
  251. message Nested {
  252. message Message {
  253. optional int32 count = 1;
  254. }
  255. }
  256. }