• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto3";
2
3package basic_test;
4
5import "google/protobuf/descriptor.proto";
6import "google/protobuf/duration.proto";
7import "google/protobuf/struct.proto";
8import "google/protobuf/timestamp.proto";
9import "google/protobuf/wrappers.proto";
10import "test_import_proto2.proto";
11
12option deprecated = true;
13
14message Foo {
15  Bar bar = 1;
16  repeated Baz baz = 2;
17}
18
19message Bar {
20  string msg = 1;
21}
22
23message Baz {
24  string msg = 1;
25}
26
27message TestMessage {
28  optional int32 optional_int32 = 1;
29  optional int64 optional_int64 = 2;
30  optional uint32 optional_uint32 = 3;
31  optional uint64 optional_uint64 = 4;
32  optional bool optional_bool = 5;
33  optional float optional_float = 6;
34  optional double optional_double = 7;
35  optional string optional_string = 8;
36  optional bytes optional_bytes = 9;
37  optional TestMessage2 optional_msg = 10;
38  optional TestEnum optional_enum = 11;
39  optional foo_bar.proto2.TestImportedMessage optional_proto2_submessage = 24;
40
41  repeated int32 repeated_int32 = 12;
42  repeated int64 repeated_int64 = 13;
43  repeated uint32 repeated_uint32 = 14;
44  repeated uint64 repeated_uint64 = 15;
45  repeated bool repeated_bool = 16;
46  repeated float repeated_float = 17;
47  repeated double repeated_double = 18;
48  repeated string repeated_string = 19;
49  repeated bytes repeated_bytes = 20;
50  repeated TestMessage2 repeated_msg = 21;
51  repeated TestEnum repeated_enum = 22;
52
53  optional TestSingularFields optional_msg2 = 23;
54}
55
56message TestUnpackedMessage {
57  repeated int32 repeated_int32 = 25 [packed = false];
58}
59
60message TestSingularFields {
61  int32 singular_int32 = 1;
62  int64 singular_int64 = 2;
63  uint32 singular_uint32 = 3;
64  uint64 singular_uint64 = 4;
65  bool singular_bool = 5;
66  float singular_float = 6;
67  double singular_double = 7;
68  string singular_string = 8;
69  bytes singular_bytes = 9;
70  TestMessage2 singular_msg = 10;
71  TestEnum singular_enum = 11;
72}
73
74message TestMessage2 {
75  optional int32 foo = 1;
76}
77
78extend google.protobuf.OneofOptions {
79  optional string test_top_level_option = 1000;
80}
81
82message TestDeprecatedMessage {
83  option deprecated = true;
84
85  extend google.protobuf.OneofOptions {
86    optional string test_nested_option = 1001;
87  }
88
89  optional int32 foo = 1 [deprecated = true];
90
91  oneof test_deprecated_message_oneof {
92    option (test_top_level_option) = "Custom option value";
93    option (test_nested_option) = "Another custom option value";
94
95    string a = 2;
96    int32 b = 3;
97  }
98
99  map<string, TestMessage2> map_string_msg = 4;
100  repeated TestMessage2 repeated_msg = 5;
101}
102
103enum TestEnum {
104  Default = 0;
105  A = 1;
106  B = 2;
107  C = 3;
108  v0 = 4;
109}
110
111enum TestDeprecatedEnum {
112  option deprecated = true;
113
114  DefaultA = 0;
115  AA = 1 [deprecated = true];
116}
117
118message TestEmbeddedMessageParent {
119  TestEmbeddedMessageChild child_msg = 1;
120  int32 number = 2;
121
122  repeated TestEmbeddedMessageChild repeated_msg = 3;
123  repeated int32 repeated_number = 4;
124}
125
126message TestEmbeddedMessageChild {
127  TestMessage sub_child = 1;
128}
129
130message Recursive1 {
131  Recursive2 foo = 1;
132}
133
134message Recursive2 {
135  Recursive1 foo = 1;
136}
137
138message MapMessage {
139  map<string, int32> map_string_int32 = 1;
140  map<string, TestMessage2> map_string_msg = 2;
141  map<string, TestEnum> map_string_enum = 3;
142}
143
144message MapMessageWireEquiv {
145  repeated MapMessageWireEquiv_entry1 map_string_int32 = 1;
146  repeated MapMessageWireEquiv_entry2 map_string_msg = 2;
147}
148
149message MapMessageWireEquiv_entry1 {
150  string key = 1;
151  int32 value = 2;
152}
153
154message MapMessageWireEquiv_entry2 {
155  string key = 1;
156  TestMessage2 value = 2;
157}
158
159message OneofMessage {
160  oneof my_oneof {
161    string a = 1;
162    int32 b = 2;
163    TestMessage2 c = 3;
164    TestEnum d = 4;
165  }
166}
167
168message Outer {
169  map<int32, Inner> items = 1;
170}
171
172message Inner {}
173
174message Wrapper {
175  google.protobuf.DoubleValue double = 1;
176  google.protobuf.FloatValue float = 2;
177  google.protobuf.Int32Value int32 = 3;
178  google.protobuf.Int64Value int64 = 4;
179  google.protobuf.UInt32Value uint32 = 5;
180  google.protobuf.UInt64Value uint64 = 6;
181  google.protobuf.BoolValue bool = 7;
182  google.protobuf.StringValue string = 8;
183  google.protobuf.BytesValue bytes = 9;
184  string real_string = 100;
185  oneof a_oneof {
186    string string_in_oneof = 10;
187  }
188
189  // Repeated wrappers don't make sense, but we still need to make sure they
190  // work and don't crash.
191  repeated google.protobuf.DoubleValue repeated_double = 11;
192  repeated google.protobuf.FloatValue repeated_float = 12;
193  repeated google.protobuf.Int32Value repeated_int32 = 13;
194  repeated google.protobuf.Int64Value repeated_int64 = 14;
195  repeated google.protobuf.UInt32Value repeated_uint32 = 15;
196  repeated google.protobuf.UInt64Value repeated_uint64 = 16;
197  repeated google.protobuf.BoolValue repeated_bool = 17;
198  repeated google.protobuf.StringValue repeated_string = 18;
199  repeated google.protobuf.BytesValue repeated_bytes = 19;
200
201  // Wrappers as map keys don't make sense, but we still need to make sure they
202  // work and don't crash.
203  map<int32, google.protobuf.DoubleValue> map_double = 21;
204  map<int32, google.protobuf.FloatValue> map_float = 22;
205  map<int32, google.protobuf.Int32Value> map_int32 = 23;
206  map<int32, google.protobuf.Int64Value> map_int64 = 24;
207  map<int32, google.protobuf.UInt32Value> map_uint32 = 25;
208  map<int32, google.protobuf.UInt64Value> map_uint64 = 26;
209  map<int32, google.protobuf.BoolValue> map_bool = 27;
210  map<int32, google.protobuf.StringValue> map_string = 28;
211  map<int32, google.protobuf.BytesValue> map_bytes = 29;
212
213  // Wrappers in oneofs don't make sense, but we still need to make sure they
214  // work and don't crash.
215  oneof wrapper_oneof {
216    google.protobuf.DoubleValue oneof_double = 31;
217    google.protobuf.FloatValue oneof_float = 32;
218    google.protobuf.Int32Value oneof_int32 = 33;
219    google.protobuf.Int64Value oneof_int64 = 34;
220    google.protobuf.UInt32Value oneof_uint32 = 35;
221    google.protobuf.UInt64Value oneof_uint64 = 36;
222    google.protobuf.BoolValue oneof_bool = 37;
223    google.protobuf.StringValue oneof_string = 38;
224    google.protobuf.BytesValue oneof_bytes = 39;
225    string oneof_plain_string = 101;
226  }
227}
228
229message TimeMessage {
230  google.protobuf.Timestamp timestamp = 1;
231  google.protobuf.Duration duration = 2;
232}
233
234message Enumer {
235  TestEnum optional_enum = 1;
236  repeated TestEnum repeated_enum = 2;
237  string a_const = 3;
238  oneof a_oneof {
239    string str = 10;
240    TestEnum const = 11;
241  }
242}
243
244message MyRepeatedStruct {
245  repeated MyStruct structs = 1;
246}
247
248message MyStruct {
249  string string = 1;
250  google.protobuf.Struct struct = 2;
251}
252
253message WithJsonName {
254  optional int32 foo_bar = 1 [json_name = "jsonFooBar"];
255  repeated WithJsonName baz = 2 [json_name = "jsonBaz"];
256}
257
258message HelloRequest {
259  optional uint32 id = 1;
260  optional uint32 random_name_a0 = 2;
261  optional uint32 random_name_a1 = 3;
262  optional uint32 random_name_a2 = 4;
263  optional uint32 random_name_a3 = 5;
264  optional uint32 random_name_a4 = 6;
265  optional uint32 random_name_a5 = 7;
266  optional uint32 random_name_a6 = 8;
267  optional uint32 random_name_a7 = 9;
268  optional uint32 random_name_a8 = 10;
269  optional uint32 random_name_a9 = 11;
270  optional uint32 random_name_b0 = 12;
271  optional uint32 random_name_b1 = 13;
272  optional uint32 random_name_b2 = 14;
273  optional uint32 random_name_b3 = 15;
274  optional uint32 random_name_b4 = 16;
275  optional uint32 random_name_b5 = 17;
276  optional uint32 random_name_b6 = 18;
277  optional uint32 random_name_b7 = 19;
278  optional uint32 random_name_b8 = 20;
279  optional uint32 random_name_b9 = 21;
280  optional uint32 random_name_c0 = 22;
281  optional uint32 random_name_c1 = 23;
282  optional uint32 random_name_c2 = 24;
283  optional uint32 random_name_c3 = 25;
284  optional uint32 random_name_c4 = 26;
285  optional uint32 random_name_c5 = 27;
286  optional uint32 random_name_c6 = 28;
287  optional uint32 random_name_c7 = 29;
288  optional uint32 random_name_c8 = 30;
289  optional uint32 random_name_c9 = 31;
290  optional string version = 32;
291}
292
293message BadFieldNames {
294  optional int32 dup = 1;
295  optional int32 class = 2;
296}
297
298// Messages to test the fix for
299// https://github.com/protocolbuffers/protobuf/issues/8311.
300message Inner8311 {
301  // Removing either of these fixes the segfault.
302  optional string foo = 1;
303  optional string bar = 2;
304}
305
306message Outer8311 {
307  repeated Inner8311 inners = 1;
308}
309
310// Messages to test the fix for
311// https://github.com/protocolbuffers/protobuf/issues/9507
312message NpeMessage {
313  optional TestEnum9507 type = 1;
314  optional string other = 2;
315}
316
317enum TestEnum9507 {
318  Something = 0;
319}
320