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 32 syntax = "proto2"; 33 34 import "google/protobuf/any.proto"; 35 import "google/protobuf/duration.proto"; 36 import "google/protobuf/struct.proto"; 37 import "google/protobuf/timestamp.proto"; 38 import "google/protobuf/wrappers.proto"; 39 40 package jsonpb; 41 42 // Test message for holding primitive types. 43 message Simple { 44 optional bool o_bool = 1; 45 optional int32 o_int32 = 2; 46 optional int32 o_int32_str = 3; 47 optional int64 o_int64 = 4; 48 optional int64 o_int64_str = 5; 49 optional uint32 o_uint32 = 6; 50 optional uint32 o_uint32_str = 7; 51 optional uint64 o_uint64 = 8; 52 optional uint64 o_uint64_str = 9; 53 optional sint32 o_sint32 = 10; 54 optional sint32 o_sint32_str = 11; 55 optional sint64 o_sint64 = 12; 56 optional sint64 o_sint64_str = 13; 57 optional float o_float = 14; 58 optional float o_float_str = 15; 59 optional double o_double = 16; 60 optional double o_double_str = 17; 61 optional string o_string = 18; 62 optional bytes o_bytes = 19; 63 } 64 65 // Test message for holding special non-finites primitives. 66 message NonFinites { 67 optional float f_nan = 1; 68 optional float f_pinf = 2; 69 optional float f_ninf = 3; 70 optional double d_nan = 4; 71 optional double d_pinf = 5; 72 optional double d_ninf = 6; 73 } 74 75 // Test message for holding repeated primitives. 76 message Repeats { 77 repeated bool r_bool = 1; 78 repeated int32 r_int32 = 2; 79 repeated int64 r_int64 = 3; 80 repeated uint32 r_uint32 = 4; 81 repeated uint64 r_uint64 = 5; 82 repeated sint32 r_sint32 = 6; 83 repeated sint64 r_sint64 = 7; 84 repeated float r_float = 8; 85 repeated double r_double = 9; 86 repeated string r_string = 10; 87 repeated bytes r_bytes = 11; 88 } 89 90 // Test message for holding enums and nested messages. 91 message Widget { 92 enum Color { 93 RED = 0; 94 GREEN = 1; 95 BLUE = 2; 96 }; 97 optional Color color = 1; 98 repeated Color r_color = 2; 99 100 optional Simple simple = 10; 101 repeated Simple r_simple = 11; 102 103 optional Repeats repeats = 20; 104 repeated Repeats r_repeats = 21; 105 } 106 107 message Maps { 108 map<int64, string> m_int64_str = 1; 109 map<bool, Simple> m_bool_simple = 2; 110 } 111 112 message MsgWithOneof { 113 oneof union { 114 string title = 1; 115 int64 salary = 2; 116 string Country = 3; 117 string home_address = 4; 118 MsgWithRequired msg_with_required = 5; 119 } 120 } 121 122 message Real { 123 optional double value = 1; 124 extensions 100 to max; 125 } 126 127 extend Real { 128 optional string name = 124; 129 } 130 131 message Complex { 132 extend Real { 133 optional Complex real_extension = 123; 134 } 135 optional double imaginary = 1; 136 extensions 100 to max; 137 } 138 139 message KnownTypes { 140 optional google.protobuf.Any an = 14; 141 optional google.protobuf.Duration dur = 1; 142 optional google.protobuf.Struct st = 12; 143 optional google.protobuf.Timestamp ts = 2; 144 optional google.protobuf.ListValue lv = 15; 145 optional google.protobuf.Value val = 16; 146 147 optional google.protobuf.DoubleValue dbl = 3; 148 optional google.protobuf.FloatValue flt = 4; 149 optional google.protobuf.Int64Value i64 = 5; 150 optional google.protobuf.UInt64Value u64 = 6; 151 optional google.protobuf.Int32Value i32 = 7; 152 optional google.protobuf.UInt32Value u32 = 8; 153 optional google.protobuf.BoolValue bool = 9; 154 optional google.protobuf.StringValue str = 10; 155 optional google.protobuf.BytesValue bytes = 11; 156 } 157 158 // Test messages for marshaling/unmarshaling required fields. 159 message MsgWithRequired { 160 required string str = 1; 161 } 162 163 message MsgWithIndirectRequired { 164 optional MsgWithRequired subm = 1; 165 map<string, MsgWithRequired> map_field = 2; 166 repeated MsgWithRequired slice_field = 3; 167 } 168 169 message MsgWithRequiredBytes { 170 required bytes byts = 1; 171 } 172 173 message MsgWithRequiredWKT { 174 required google.protobuf.StringValue str = 1; 175 } 176 177 extend Real { 178 optional MsgWithRequired extm = 125; 179 } 180