basic_test_proto2.proto 5.1 KB

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