1// Go support for Protocol Buffers - Google's data interchange format
2//
3// Copyright 2015 The Go Authors.  All rights reserved.
4// https://github.com/golang/protobuf
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10//     * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12//     * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16//     * Neither the name of Google Inc. nor the names of its
17// contributors may be used to endorse or promote products derived from
18// this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32syntax = "proto2";
33
34import "google/protobuf/any.proto";
35import "google/protobuf/duration.proto";
36import "google/protobuf/struct.proto";
37import "google/protobuf/timestamp.proto";
38import "google/protobuf/wrappers.proto";
39
40package jsonpb;
41
42import weak "gogoproto/gogo.proto";
43
44// Test message for holding primitive types.
45message Simple {
46  optional bool o_bool = 1;
47  optional int32 o_int32 = 2;
48  optional int32 o_int32_str = 3;
49  optional int64 o_int64 = 4;
50  optional int64 o_int64_str = 5;
51  optional uint32 o_uint32 = 6;
52  optional uint32 o_uint32_str = 7;
53  optional uint64 o_uint64 = 8;
54  optional uint64 o_uint64_str = 9;
55  optional sint32 o_sint32 = 10;
56  optional sint32 o_sint32_str = 11;
57  optional sint64 o_sint64 = 12;
58  optional sint64 o_sint64_str = 13;
59  optional float o_float = 14;
60  optional float o_float_str = 15;
61  optional double o_double = 16;
62  optional double o_double_str = 17;
63  optional string o_string = 18;
64  optional bytes o_bytes = 19;
65  optional bytes o_cast_bytes = 20 [(gogoproto.casttype) = "Bytes"];
66}
67
68// Test message for holding special non-finites primitives.
69message NonFinites {
70    optional float f_nan = 1;
71    optional float f_pinf = 2;
72    optional float f_ninf = 3;
73    optional double d_nan = 4;
74    optional double d_pinf = 5;
75    optional double d_ninf = 6;
76}
77
78
79// Test message for holding repeated primitives.
80message Repeats {
81  repeated bool r_bool = 1;
82  repeated int32 r_int32 = 2;
83  repeated int64 r_int64 = 3;
84  repeated uint32 r_uint32 = 4;
85  repeated uint64 r_uint64 = 5;
86  repeated sint32 r_sint32 = 6;
87  repeated sint64 r_sint64 = 7;
88  repeated float r_float = 8;
89  repeated double r_double = 9;
90  repeated string r_string = 10;
91  repeated bytes r_bytes = 11;
92}
93
94// Test message for holding enums and nested messages.
95message Widget {
96  enum Color {
97    RED = 0;
98    GREEN = 1;
99    BLUE = 2;
100  };
101  optional Color color = 1;
102  repeated Color r_color = 2;
103
104  optional Simple simple = 10;
105  repeated Simple r_simple = 11;
106
107  optional Repeats repeats = 20;
108  repeated Repeats r_repeats = 21;
109}
110
111message Maps {
112  map<int64, string> m_int64_str = 1;
113  map<bool, Simple> m_bool_simple = 2;
114}
115
116message MsgWithOneof {
117  oneof union {
118    string title = 1;
119    int64 salary = 2;
120    string Country = 3;
121    string home_address = 4;
122    MsgWithRequired msg_with_required = 5;
123  }
124}
125
126message Real {
127  optional double value = 1;
128  extensions 100 to max;
129}
130
131extend Real {
132  optional string name = 124;
133}
134
135message Complex {
136  extend Real {
137    optional Complex real_extension = 123;
138  }
139  optional double imaginary = 1;
140  extensions 100 to max;
141}
142
143message KnownTypes {
144  optional google.protobuf.Any an = 14;
145  optional google.protobuf.Duration dur = 1;
146  optional google.protobuf.Struct st = 12;
147  optional google.protobuf.Timestamp ts = 2;
148  optional google.protobuf.ListValue lv = 15;
149  optional google.protobuf.Value val = 16;
150
151  optional google.protobuf.DoubleValue dbl = 3;
152  optional google.protobuf.FloatValue flt = 4;
153  optional google.protobuf.Int64Value i64 = 5;
154  optional google.protobuf.UInt64Value u64 = 6;
155  optional google.protobuf.Int32Value i32 = 7;
156  optional google.protobuf.UInt32Value u32 = 8;
157  optional google.protobuf.BoolValue bool = 9;
158  optional google.protobuf.StringValue str = 10;
159  optional google.protobuf.BytesValue bytes = 11;
160}
161
162// Test messages for marshaling/unmarshaling required fields.
163message MsgWithRequired {
164  required string str = 1;
165}
166
167message MsgWithIndirectRequired {
168  optional MsgWithRequired subm = 1;
169  map<string, MsgWithRequired> map_field = 2;
170  repeated MsgWithRequired slice_field = 3;
171}
172
173message MsgWithRequiredBytes {
174  required bytes byts = 1;
175}
176
177message MsgWithRequiredWKT {
178  required google.protobuf.StringValue str = 1;
179}
180
181extend Real {
182  optional MsgWithRequired extm = 125;
183}
184