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
31syntax = "proto3";
32
33package json_test;
34
35import "google/protobuf/any.proto";
36import "google/protobuf/duration.proto";
37import "google/protobuf/field_mask.proto";
38import "google/protobuf/struct.proto";
39import "google/protobuf/timestamp.proto";
40import "google/protobuf/wrappers.proto";
41
42option java_package = "com.google.protobuf.util.proto";
43option java_outer_classname = "JsonTestProto";
44
45message TestAllTypes {
46  enum NestedEnum {
47    FOO = 0;
48    BAR = 1;
49    BAZ = 2;
50  }
51
52  enum AliasedEnum {
53    option allow_alias = true;
54
55    ALIAS_FOO = 0;
56    ALIAS_BAR = 1;
57    ALIAS_BAZ = 2;
58    QUX = 2;
59    qux = 2;
60    bAz = 2;
61  }
62  message NestedMessage {
63    int32 value = 1;
64  }
65
66  int32 optional_int32 = 1;
67  int64 optional_int64 = 2;
68  uint32 optional_uint32 = 3;
69  uint64 optional_uint64 = 4;
70  sint32 optional_sint32 = 5;
71  sint64 optional_sint64 = 6;
72  fixed32 optional_fixed32 = 7;
73  fixed64 optional_fixed64 = 8;
74  sfixed32 optional_sfixed32 = 9;
75  sfixed64 optional_sfixed64 = 10;
76  float optional_float = 11;
77  double optional_double = 12;
78  bool optional_bool = 13;
79  string optional_string = 14;
80  bytes optional_bytes = 15;
81  NestedMessage optional_nested_message = 18;
82  NestedEnum optional_nested_enum = 21;
83  AliasedEnum optional_aliased_enum = 52;
84
85  // Repeated
86  repeated int32 repeated_int32 = 31;
87  repeated int64 repeated_int64 = 32;
88  repeated uint32 repeated_uint32 = 33;
89  repeated uint64 repeated_uint64 = 34;
90  repeated sint32 repeated_sint32 = 35;
91  repeated sint64 repeated_sint64 = 36;
92  repeated fixed32 repeated_fixed32 = 37;
93  repeated fixed64 repeated_fixed64 = 38;
94  repeated sfixed32 repeated_sfixed32 = 39;
95  repeated sfixed64 repeated_sfixed64 = 40;
96  repeated float repeated_float = 41;
97  repeated double repeated_double = 42;
98  repeated bool repeated_bool = 43;
99  repeated string repeated_string = 44;
100  repeated bytes repeated_bytes = 45;
101  repeated NestedMessage repeated_nested_message = 48;
102  repeated NestedEnum repeated_nested_enum = 51;
103}
104
105message TestOneof {
106  oneof oneof_field {
107    int32 oneof_int32 = 1;
108    TestAllTypes.NestedMessage oneof_nested_message = 2;
109    google.protobuf.NullValue oneof_null_value = 3;
110  }
111}
112
113message TestMap {
114  // Instead of testing all combinations (too many), we only make sure all
115  // valid types have been used at least in one field as key and in one
116  // field as value.
117  map<int32, int32> int32_to_int32_map = 1;
118  map<int64, int32> int64_to_int32_map = 2;
119  map<uint32, int32> uint32_to_int32_map = 3;
120  map<uint64, int32> uint64_to_int32_map = 4;
121  map<sint32, int32> sint32_to_int32_map = 5;
122  map<sint64, int32> sint64_to_int32_map = 6;
123  map<fixed32, int32> fixed32_to_int32_map = 7;
124  map<fixed64, int32> fixed64_to_int32_map = 8;
125  map<sfixed32, int32> sfixed32_to_int32_map = 9;
126  map<sfixed64, int32> sfixed64_to_int32_map = 10;
127  map<bool, int32> bool_to_int32_map = 11;
128  map<string, int32> string_to_int32_map = 12;
129
130  map<int32, int64> int32_to_int64_map = 101;
131  map<int32, uint32> int32_to_uint32_map = 102;
132  map<int32, uint64> int32_to_uint64_map = 103;
133  map<int32, sint32> int32_to_sint32_map = 104;
134  map<int32, sint64> int32_to_sint64_map = 105;
135  map<int32, fixed32> int32_to_fixed32_map = 106;
136  map<int32, fixed64> int32_to_fixed64_map = 107;
137  map<int32, sfixed32> int32_to_sfixed32_map = 108;
138  map<int32, sfixed64> int32_to_sfixed64_map = 109;
139  map<int32, float> int32_to_float_map = 110;
140  map<int32, double> int32_to_double_map = 111;
141  map<int32, bool> int32_to_bool_map = 112;
142  map<int32, string> int32_to_string_map = 113;
143  map<int32, bytes> int32_to_bytes_map = 114;
144  map<int32, TestAllTypes.NestedMessage> int32_to_message_map = 115;
145  map<int32, TestAllTypes.NestedEnum> int32_to_enum_map = 116;
146}
147
148message TestWrappers {
149  google.protobuf.Int32Value int32_value = 1;
150  google.protobuf.UInt32Value uint32_value = 2;
151  google.protobuf.Int64Value int64_value = 3;
152  google.protobuf.UInt64Value uint64_value = 4;
153  google.protobuf.FloatValue float_value = 5;
154  google.protobuf.DoubleValue double_value = 6;
155  google.protobuf.BoolValue bool_value = 7;
156  google.protobuf.StringValue string_value = 8;
157  google.protobuf.BytesValue bytes_value = 9;
158}
159
160message TestTimestamp {
161  google.protobuf.Timestamp timestamp_value = 1;
162}
163
164message TestDuration {
165  google.protobuf.Duration duration_value = 1;
166}
167
168message TestFieldMask {
169  google.protobuf.FieldMask field_mask_value = 1;
170}
171
172message TestStruct {
173  google.protobuf.Struct struct_value = 1;
174  google.protobuf.Value value = 2;
175  google.protobuf.ListValue list_value = 3;
176}
177
178message TestAny {
179  google.protobuf.Any any_value = 1;
180  map<string, google.protobuf.Any> any_map = 2;
181}
182
183message TestCustomJsonName {
184  int32 value = 1 [json_name = "@value"];
185}
186
187message TestRecursive {
188  int32 value = 1;
189  TestRecursive nested = 2;
190}
191