1syntax = "proto2"; 2 3package basic_test_proto2; 4 5import "google/protobuf/wrappers.proto"; 6import "google/protobuf/timestamp.proto"; 7import "google/protobuf/duration.proto"; 8import "google/protobuf/struct.proto"; 9 10message Foo { 11 optional Bar bar = 1; 12 repeated Baz baz = 2; 13} 14 15message Bar { 16 optional string msg = 1; 17} 18 19message Baz { 20 optional string msg = 1; 21} 22 23message TestMessage { 24 optional int32 optional_int32 = 1; 25 optional int64 optional_int64 = 2; 26 optional uint32 optional_uint32 = 3; 27 optional uint64 optional_uint64 = 4; 28 optional bool optional_bool = 5; 29 optional float optional_float = 6; 30 optional double optional_double = 7; 31 optional string optional_string = 8; 32 optional bytes optional_bytes = 9; 33 optional TestMessage2 optional_msg = 10; 34 optional TestEnum optional_enum = 11; 35 36 repeated int32 repeated_int32 = 12; 37 repeated int64 repeated_int64 = 13; 38 repeated uint32 repeated_uint32 = 14; 39 repeated uint64 repeated_uint64 = 15; 40 repeated bool repeated_bool = 16; 41 repeated float repeated_float = 17; 42 repeated double repeated_double = 18; 43 repeated string repeated_string = 19; 44 repeated bytes repeated_bytes = 20; 45 repeated TestMessage2 repeated_msg = 21; 46 repeated TestEnum repeated_enum = 22; 47} 48 49message TestMessage2 { 50 optional int32 foo = 1; 51} 52 53message TestMessageDefaults { 54 optional int32 optional_int32 = 1 [default = 1]; 55 optional int64 optional_int64 = 2 [default = 2]; 56 optional uint32 optional_uint32 = 3 [default = 3]; 57 optional uint64 optional_uint64 = 4 [default = 4]; 58 optional bool optional_bool = 5 [default = true]; 59 optional float optional_float = 6 [default = 6]; 60 optional double optional_double = 7 [default = 7]; 61 optional string optional_string = 8 [default = "Default Str"]; 62 optional bytes optional_bytes = 9 [default = "\xCF\xA5s\xBD\xBA\xE6fubar"]; 63 optional TestMessage2 optional_msg = 10; 64 optional TestNonZeroEnum optional_enum = 11 [default = B2]; 65} 66 67enum TestEnum { 68 Default = 0; 69 A = 1; 70 B = 2; 71 C = 3; 72} 73 74enum TestNonZeroEnum { 75 A2 = 1; 76 B2 = 2; 77 C2 = 3; 78} 79 80message TestEmbeddedMessageParent { 81 optional TestEmbeddedMessageChild child_msg = 1; 82 optional int32 number = 2; 83 84 repeated TestEmbeddedMessageChild repeated_msg = 3; 85 repeated int32 repeated_number = 4; 86} 87 88message TestEmbeddedMessageChild { 89 optional TestMessage sub_child = 1; 90} 91 92message Recursive1 { 93 optional Recursive2 foo = 1; 94} 95 96message Recursive2 { 97 optional Recursive1 foo = 1; 98} 99 100message MapMessageWireEquiv { 101 repeated MapMessageWireEquiv_entry1 map_string_int32 = 1; 102 repeated MapMessageWireEquiv_entry2 map_string_msg = 2; 103} 104 105message MapMessageWireEquiv_entry1 { 106 optional string key = 1; 107 optional int32 value = 2; 108} 109 110message MapMessageWireEquiv_entry2 { 111 optional string key = 1; 112 optional TestMessage2 value = 2; 113} 114 115message OneofMessage { 116 oneof my_oneof { 117 string a = 1; 118 int32 b = 2; 119 TestMessage2 c = 3; 120 TestEnum d = 4; 121 } 122} 123 124message Wrapper { 125 optional google.protobuf.DoubleValue double = 1; 126 optional google.protobuf.FloatValue float = 2; 127 optional google.protobuf.Int32Value int32 = 3; 128 optional google.protobuf.Int64Value int64 = 4; 129 optional google.protobuf.UInt32Value uint32 = 5; 130 optional google.protobuf.UInt64Value uint64 = 6; 131 optional google.protobuf.BoolValue bool = 7; 132 optional google.protobuf.StringValue string = 8; 133 optional google.protobuf.BytesValue bytes = 9; 134 optional string real_string = 100; 135 oneof a_oneof { 136 string string_in_oneof = 10; 137 } 138 139 // Repeated wrappers don't really make sense, but we still need to make sure 140 // they work and don't crash. 141 repeated google.protobuf.DoubleValue repeated_double = 11; 142 repeated google.protobuf.FloatValue repeated_float = 12; 143 repeated google.protobuf.Int32Value repeated_int32 = 13; 144 repeated google.protobuf.Int64Value repeated_int64 = 14; 145 repeated google.protobuf.UInt32Value repeated_uint32 = 15; 146 repeated google.protobuf.UInt64Value repeated_uint64 = 16; 147 repeated google.protobuf.BoolValue repeated_bool = 17; 148 repeated google.protobuf.StringValue repeated_string = 18; 149 repeated google.protobuf.BytesValue repeated_bytes = 19; 150 151 // Wrappers in oneofs don't make sense, but we still need to make sure they 152 // work and don't crash. 153 oneof wrapper_oneof { 154 google.protobuf.DoubleValue oneof_double = 31; 155 google.protobuf.FloatValue oneof_float = 32; 156 google.protobuf.Int32Value oneof_int32 = 33; 157 google.protobuf.Int64Value oneof_int64 = 34; 158 google.protobuf.UInt32Value oneof_uint32 = 35; 159 google.protobuf.UInt64Value oneof_uint64 = 36; 160 google.protobuf.BoolValue oneof_bool = 37; 161 google.protobuf.StringValue oneof_string = 38; 162 google.protobuf.BytesValue oneof_bytes = 39; 163 string oneof_plain_string = 101; 164 } 165} 166 167message TimeMessage { 168 optional google.protobuf.Timestamp timestamp = 1; 169 optional google.protobuf.Duration duration = 2; 170} 171 172message Enumer { 173 optional TestEnum optional_enum = 11; 174 repeated TestEnum repeated_enum = 22; 175 optional string a_const = 3; 176 oneof a_oneof { 177 string str = 100; 178 TestEnum const = 101; 179 } 180} 181 182message MyRepeatedStruct { 183 repeated MyStruct structs = 1; 184} 185 186message MyStruct { 187 optional string string = 1; 188 optional google.protobuf.Struct struct = 2; 189} 190