test.proto 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. // LINT: LEGACY_NAMES
  31. // Author: mwr@google.com (Mark Rawling)
  32. syntax = "proto2";
  33. option java_package = "com.google.apps.jspb.proto";
  34. option java_multiple_files = true;
  35. import "google/protobuf/descriptor.proto";
  36. package jspb.test;
  37. message Empty {}
  38. enum OuterEnum {
  39. FOO = 1;
  40. BAR = 2;
  41. }
  42. message EnumContainer {
  43. optional OuterEnum outer_enum = 1;
  44. }
  45. message Simple1 {
  46. required string a_string = 1;
  47. repeated string a_repeated_string = 2;
  48. optional bool a_boolean = 3;
  49. }
  50. // A message that differs from Simple1 only by name
  51. message Simple2 {
  52. required string a_string = 1;
  53. repeated string a_repeated_string = 2;
  54. }
  55. message SpecialCases {
  56. required string normal = 1;
  57. // Examples of Js reserved names that are converted to pb_<name>.
  58. required string default = 2;
  59. required string function = 3;
  60. required string var = 4;
  61. }
  62. message OptionalFields {
  63. message Nested {
  64. optional int32 an_int = 1;
  65. }
  66. optional string a_string = 1;
  67. required bool a_bool = 2;
  68. optional Nested a_nested_message = 3;
  69. repeated Nested a_repeated_message = 4;
  70. repeated string a_repeated_string = 5;
  71. }
  72. message HasExtensions {
  73. optional string str1 = 1;
  74. optional string str2 = 2;
  75. optional string str3 = 3;
  76. extensions 10 to max;
  77. }
  78. message Complex {
  79. message Nested {
  80. required int32 an_int = 2;
  81. }
  82. required string a_string = 1;
  83. optional bool an_out_of_order_bool = 9;
  84. optional Nested a_nested_message = 4;
  85. repeated Nested a_repeated_message = 5;
  86. repeated string a_repeated_string = 7;
  87. optional double a_floating_point_field = 10;
  88. }
  89. message OuterMessage {
  90. // Make sure this doesn't conflict with the other Complex message.
  91. message Complex {
  92. optional int32 inner_complex_field = 1;
  93. }
  94. }
  95. message MineField {
  96. // document.cookie is a banned property in a couple of conformance check
  97. // configs at Google. Verify that having a field called cookie doesn't confuse
  98. // the compiler and break the build.
  99. optional string cookie = 1;
  100. }
  101. message IsExtension {
  102. extend HasExtensions {
  103. optional IsExtension ext_field = 100;
  104. }
  105. optional string ext1 = 1;
  106. // Extensions of proto2 Descriptor messages will be ignored.
  107. extend google.protobuf.EnumOptions {
  108. optional string simple_option = 42113038;
  109. }
  110. }
  111. message IndirectExtension {
  112. extend HasExtensions {
  113. optional Simple1 simple = 101;
  114. optional string str = 102;
  115. repeated string repeated_str = 103;
  116. repeated Simple1 repeated_simple = 104;
  117. }
  118. }
  119. extend HasExtensions {
  120. optional Simple1 simple1 = 105;
  121. }
  122. message DefaultValues {
  123. enum Enum {
  124. E1 = 13;
  125. E2 = 77;
  126. }
  127. optional string string_field = 1 [default = "default<>\'\"abc"];
  128. optional bool bool_field = 2 [default = true];
  129. optional int64 int_field = 3 [default = 11];
  130. optional Enum enum_field = 4 [default = E1];
  131. optional string empty_field = 6 [default = ""];
  132. optional bytes bytes_field = 8
  133. [default = "moo"]; // Base64 encoding is "bW9v"
  134. }
  135. message FloatingPointFields {
  136. optional float optional_float_field = 1;
  137. required float required_float_field = 2;
  138. repeated float repeated_float_field = 3;
  139. optional float default_float_field = 4 [default = 2.0];
  140. optional double optional_double_field = 5;
  141. required double required_double_field = 6;
  142. repeated double repeated_double_field = 7;
  143. optional double default_double_field = 8 [default = 2.0];
  144. }
  145. message BooleanFields {
  146. optional bool optional_boolean_field = 1;
  147. required bool required_boolean_field = 2;
  148. repeated bool repeated_boolean_field = 3;
  149. optional bool default_boolean_field = 4 [default = true];
  150. }
  151. message TestClone {
  152. optional string str = 1;
  153. optional Simple1 simple1 = 3;
  154. repeated Simple1 simple2 = 5;
  155. optional bytes bytes_field = 6;
  156. optional string unused = 7;
  157. extensions 10 to max;
  158. }
  159. message TestCloneExtension {
  160. extend TestClone {
  161. optional TestCloneExtension low_ext = 11;
  162. }
  163. optional int32 f = 1;
  164. }
  165. message CloneExtension {
  166. extend TestClone {
  167. optional CloneExtension ext_field = 100;
  168. }
  169. optional string ext = 2;
  170. }
  171. message TestGroup {
  172. repeated group RepeatedGroup = 1 {
  173. required string id = 1;
  174. repeated bool some_bool = 2;
  175. }
  176. required group RequiredGroup = 2 {
  177. required string id = 1;
  178. }
  179. optional group OptionalGroup = 3 {
  180. required string id = 1;
  181. }
  182. optional string id = 4;
  183. required Simple2 required_simple = 5;
  184. optional Simple2 optional_simple = 6;
  185. }
  186. message TestGroup1 {
  187. optional TestGroup.RepeatedGroup group = 1;
  188. }
  189. message TestReservedNames {
  190. optional int32 extension = 1;
  191. extensions 10 to max;
  192. }
  193. message TestReservedNamesExtension {
  194. extend TestReservedNames {
  195. optional int32 foo = 10;
  196. }
  197. }
  198. message TestMessageWithOneof {
  199. oneof partial_oneof {
  200. string pone = 3;
  201. string pthree = 5;
  202. }
  203. oneof recursive_oneof {
  204. TestMessageWithOneof rone = 6;
  205. string rtwo = 7;
  206. }
  207. optional bool normal_field = 8;
  208. repeated string repeated_field = 9;
  209. oneof default_oneof_a {
  210. int32 aone = 10 [default = 1234];
  211. int32 atwo = 11;
  212. }
  213. oneof default_oneof_b {
  214. int32 bone = 12;
  215. int32 btwo = 13 [default = 1234];
  216. }
  217. }
  218. message TestEndsWithBytes {
  219. optional int32 value = 1;
  220. optional bytes data = 2;
  221. }
  222. // This message is for testing extension handling doesn't affect fields before
  223. // pivot. Don't add new field to this message. See b/117298778 for more detail.
  224. message TestLastFieldBeforePivot {
  225. optional int32 last_field_before_pivot = 1;
  226. extensions 100 to max;
  227. }
  228. extend TestLastFieldBeforePivot {
  229. optional int32 extend_test_last_field_before_pivot_field = 101;
  230. }
  231. message Int64Types {
  232. optional int64 int64_normal = 1 [jstype = JS_NORMAL];
  233. optional sint64 int64_string = 2 [jstype = JS_STRING];
  234. optional uint64 int64_number = 3 [jstype = JS_NUMBER];
  235. }
  236. message TestMapFieldsNoBinary {
  237. map<string, string> map_string_string = 1;
  238. map<string, int32> map_string_int32 = 2;
  239. map<string, int64> map_string_int64 = 3;
  240. map<string, bool> map_string_bool = 4;
  241. map<string, double> map_string_double = 5;
  242. map<string, MapValueEnumNoBinary> map_string_enum = 6;
  243. map<string, MapValueMessageNoBinary> map_string_msg = 7;
  244. map<int32, string> map_int32_string = 8;
  245. map<int64, string> map_int64_string = 9;
  246. map<bool, string> map_bool_string = 10;
  247. optional TestMapFieldsNoBinary test_map_fields = 11;
  248. map<string, TestMapFieldsNoBinary> map_string_testmapfields = 12;
  249. }
  250. enum MapValueEnumNoBinary {
  251. MAP_VALUE_FOO_NOBINARY = 0;
  252. MAP_VALUE_BAR_NOBINARY = 1;
  253. MAP_VALUE_BAZ_NOBINARY = 2;
  254. }
  255. message MapValueMessageNoBinary {
  256. optional int32 foo = 1;
  257. }
  258. message Deeply {
  259. message Nested {
  260. message Message {
  261. optional int32 count = 1;
  262. }
  263. }
  264. }
  265. enum TestAllowAliasEnum {
  266. option allow_alias = true;
  267. TEST_ALLOW_ALIAS_DEFAULT = 0;
  268. VALUE1 = 1;
  269. value1 = 1;
  270. }