test_objects.proto 5.2 KB

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