test.proto 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. }
  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. required 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. }
  88. message IsExtension {
  89. extend HasExtensions {
  90. optional IsExtension ext_field = 100;
  91. }
  92. optional string ext1 = 1;
  93. // Extensions of proto2 Descriptor messages will be ignored.
  94. extend google.protobuf.EnumOptions {
  95. optional string simple_option = 42113038;
  96. }
  97. }
  98. message IndirectExtension {
  99. extend HasExtensions {
  100. optional Simple1 simple = 101;
  101. optional string str = 102;
  102. repeated string repeated_str = 103;
  103. repeated Simple1 repeated_simple = 104;
  104. }
  105. }
  106. extend HasExtensions {
  107. optional Simple1 simple1 = 105;
  108. }
  109. message DefaultValues {
  110. enum Enum {
  111. E1 = 13;
  112. E2 = 77;
  113. }
  114. optional string string_field = 1 [default="default<>\'\"abc"];
  115. optional bool bool_field = 2 [default=true];
  116. optional int64 int_field = 3 [default=11];
  117. optional Enum enum_field = 4 [default=E1];
  118. optional string empty_field = 6 [default=""];
  119. optional bytes bytes_field = 8 [default="moo"]; // Base64 encoding is "bW9v"
  120. }
  121. message TestClone {
  122. optional string str = 1;
  123. optional Simple1 simple1 = 3;
  124. repeated Simple1 simple2 = 5;
  125. optional string unused = 7;
  126. extensions 10 to max;
  127. }
  128. message CloneExtension {
  129. extend TestClone {
  130. optional CloneExtension ext_field = 100;
  131. }
  132. optional string ext = 2;
  133. }
  134. message TestGroup {
  135. repeated group RepeatedGroup = 1 {
  136. required string id = 1;
  137. repeated bool some_bool = 2;
  138. }
  139. required group RequiredGroup = 2 {
  140. required string id = 1;
  141. }
  142. optional group OptionalGroup = 3 {
  143. required string id = 1;
  144. }
  145. optional string id = 4;
  146. required Simple2 required_simple = 5;
  147. optional Simple2 optional_simple = 6;
  148. }
  149. message TestGroup1 {
  150. optional TestGroup.RepeatedGroup group = 1;
  151. }
  152. message TestReservedNames {
  153. optional int32 extension = 1;
  154. extensions 10 to max;
  155. }
  156. message TestReservedNamesExtension {
  157. extend TestReservedNames {
  158. optional int32 foo = 10;
  159. }
  160. }
  161. message TestMessageWithOneof {
  162. oneof partial_oneof {
  163. string pone = 3;
  164. string pthree = 5;
  165. }
  166. oneof recursive_oneof {
  167. TestMessageWithOneof rone = 6;
  168. string rtwo = 7;
  169. }
  170. optional bool normal_field = 8;
  171. repeated string repeated_field = 9;
  172. oneof default_oneof_a {
  173. int32 aone = 10 [default = 1234];
  174. int32 atwo = 11;
  175. }
  176. oneof default_oneof_b {
  177. int32 bone = 12;
  178. int32 btwo = 13 [default = 1234];
  179. }
  180. }