test_objects.proto 4.9 KB

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