test_objects.proto 5.3 KB

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