test.proto 8.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

31
// LINT: LEGACY_NAMES
32 33 34 35 36 37 38 39 40 41 42
// Author: mwr@google.com (Mark Rawling)

syntax = "proto2";

option java_package = "com.google.apps.jspb.proto";
option java_multiple_files = true;

import "google/protobuf/descriptor.proto";

package jspb.test;

43
message Empty {}
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

enum OuterEnum {
  FOO = 1;
  BAR = 2;
}

message EnumContainer {
  optional OuterEnum outer_enum = 1;
}

message Simple1 {
  required string a_string = 1;
  repeated string a_repeated_string = 2;
  optional bool a_boolean = 3;
}

// A message that differs from Simple1 only by name
message Simple2 {
  required string a_string = 1;
  repeated string a_repeated_string = 2;
}

message SpecialCases {
  required string normal = 1;
  // Examples of Js reserved names that are converted to pb_<name>.
  required string default = 2;
  required string function = 3;
  required string var = 4;
}

message OptionalFields {
  message Nested {
    optional int32 an_int = 1;
  }
  optional string a_string = 1;
  required bool a_bool = 2;
  optional Nested a_nested_message = 3;
  repeated Nested a_repeated_message = 4;
  repeated string a_repeated_string = 5;
}

message HasExtensions {
  optional string str1 = 1;
  optional string str2 = 2;
  optional string str3 = 3;
  extensions 10 to max;
}

message Complex {
  message Nested {
    required int32 an_int = 2;
  }
  required string a_string = 1;
97
  optional bool an_out_of_order_bool = 9;
98 99 100
  optional Nested a_nested_message = 4;
  repeated Nested a_repeated_message = 5;
  repeated string a_repeated_string = 7;
101
  optional double a_floating_point_field = 10;
102 103
}

104 105 106 107 108 109 110
message OuterMessage {
  // Make sure this doesn't conflict with the other Complex message.
  message Complex {
    optional int32 inner_complex_field = 1;
  }
}

111 112 113 114 115 116 117
message MineField {
  // document.cookie is a banned property in a couple of conformance check
  // configs at Google. Verify that having a field called cookie doesn't confuse
  // the compiler and break the build.
  optional string cookie = 1;
}

118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
message IsExtension {
  extend HasExtensions {
    optional IsExtension ext_field = 100;
  }
  optional string ext1 = 1;

  // Extensions of proto2 Descriptor messages will be ignored.
  extend google.protobuf.EnumOptions {
    optional string simple_option = 42113038;
  }
}

message IndirectExtension {
  extend HasExtensions {
    optional Simple1 simple = 101;
    optional string str = 102;
    repeated string repeated_str = 103;
    repeated Simple1 repeated_simple = 104;
  }
}

extend HasExtensions {
  optional Simple1 simple1 = 105;
}

message DefaultValues {
  enum Enum {
    E1 = 13;
    E2 = 77;
  }
148 149 150 151 152 153 154
  optional string string_field = 1 [default = "default<>\'\"abc"];
  optional bool bool_field = 2 [default = true];
  optional int64 int_field = 3 [default = 11];
  optional Enum enum_field = 4 [default = E1];
  optional string empty_field = 6 [default = ""];
  optional bytes bytes_field = 8
      [default = "moo"];  // Base64 encoding is "bW9v"
155 156
}

157 158 159 160 161 162 163 164 165 166 167
message FloatingPointFields {
  optional float optional_float_field = 1;
  required float required_float_field = 2;
  repeated float repeated_float_field = 3;
  optional float default_float_field = 4 [default = 2.0];
  optional double optional_double_field = 5;
  required double required_double_field = 6;
  repeated double repeated_double_field = 7;
  optional double default_double_field = 8 [default = 2.0];
}

168 169 170 171 172 173 174
message BooleanFields {
  optional bool optional_boolean_field = 1;
  required bool required_boolean_field = 2;
  repeated bool repeated_boolean_field = 3;
  optional bool default_boolean_field = 4 [default = true];
}

175 176 177 178
message TestClone {
  optional string str = 1;
  optional Simple1 simple1 = 3;
  repeated Simple1 simple2 = 5;
179
  optional bytes bytes_field = 6;
180 181 182 183
  optional string unused = 7;
  extensions 10 to max;
}

184 185 186 187 188 189 190
message TestCloneExtension {
  extend TestClone {
    optional TestCloneExtension low_ext = 11;
  }
  optional int32 f = 1;
}

191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
message CloneExtension {
  extend TestClone {
    optional CloneExtension ext_field = 100;
  }
  optional string ext = 2;
}

message TestGroup {
  repeated group RepeatedGroup = 1 {
    required string id = 1;
    repeated bool some_bool = 2;
  }
  required group RequiredGroup = 2 {
    required string id = 1;
  }
  optional group OptionalGroup = 3 {
    required string id = 1;
  }
  optional string id = 4;
  required Simple2 required_simple = 5;
  optional Simple2 optional_simple = 6;
}

message TestGroup1 {
  optional TestGroup.RepeatedGroup group = 1;
}

message TestReservedNames {
  optional int32 extension = 1;
  extensions 10 to max;
}

message TestReservedNamesExtension {
  extend TestReservedNames {
    optional int32 foo = 10;
  }
}

message TestMessageWithOneof {

  oneof partial_oneof {
    string pone = 3;
    string pthree = 5;
  }

  oneof recursive_oneof {
    TestMessageWithOneof rone = 6;
    string rtwo = 7;
  }

  optional bool normal_field = 8;
  repeated string repeated_field = 9;

  oneof default_oneof_a {
    int32 aone = 10 [default = 1234];
    int32 atwo = 11;
  }

  oneof default_oneof_b {
    int32 bone = 12;
    int32 btwo = 13 [default = 1234];
  }
}
254

Adam Cozzette's avatar
Adam Cozzette committed
255 256 257 258
message TestEndsWithBytes {
  optional int32 value = 1;
  optional bytes data = 2;
}
259

260 261 262 263 264 265 266 267 268 269 270
// This message is for testing extension handling doesn't affect fields before
// pivot. Don't add new field to this message. See b/117298778 for more detail.
message TestLastFieldBeforePivot {
  optional int32 last_field_before_pivot = 1;
  extensions 100 to max;
}

extend TestLastFieldBeforePivot {
  optional int32 extend_test_last_field_before_pivot_field = 101;
}

271

272
message Int64Types {
273 274 275
  optional int64 int64_normal = 1 [jstype = JS_NORMAL];
  optional sint64 int64_string = 2 [jstype = JS_STRING];
  optional uint64 int64_number = 3 [jstype = JS_NUMBER];
276 277 278

}

279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
message TestMapFieldsNoBinary {
  map<string, string> map_string_string = 1;
  map<string, int32> map_string_int32 = 2;
  map<string, int64> map_string_int64 = 3;
  map<string, bool> map_string_bool = 4;
  map<string, double> map_string_double = 5;
  map<string, MapValueEnumNoBinary> map_string_enum = 6;
  map<string, MapValueMessageNoBinary> map_string_msg = 7;

  map<int32, string> map_int32_string = 8;
  map<int64, string> map_int64_string = 9;
  map<bool, string> map_bool_string = 10;

  optional TestMapFieldsNoBinary test_map_fields = 11;
  map<string, TestMapFieldsNoBinary> map_string_testmapfields = 12;
}

enum MapValueEnumNoBinary {
297 298 299
  MAP_VALUE_FOO_NOBINARY = 0;
  MAP_VALUE_BAR_NOBINARY = 1;
  MAP_VALUE_BAZ_NOBINARY = 2;
300 301 302 303 304
}

message MapValueMessageNoBinary {
  optional int32 foo = 1;
}
305 306 307 308 309 310 311 312

message Deeply {
  message Nested {
    message Message {
      optional int32 count = 1;
    }
  }
}
313

314

315 316 317 318 319 320 321 322

enum TestAllowAliasEnum {
  option allow_alias = true;

  TEST_ALLOW_ALIAS_DEFAULT = 0;
  VALUE1 = 1;
  value1 = 1;
}