descriptor.proto 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // Author: kenton@google.com (Kenton Varda)
  31. // Based on original Protocol Buffers design by
  32. // Sanjay Ghemawat, Jeff Dean, and others.
  33. //
  34. // The messages in this file describe the definitions found in .proto files.
  35. // A valid .proto file can be translated directly to a FileDescriptorProto
  36. // without any other information (e.g. without reading its imports).
  37. syntax = "proto2";
  38. package google.protobuf;
  39. option go_package = "google.golang.org/protobuf/types/descriptorpb";
  40. option java_package = "com.google.protobuf";
  41. option java_outer_classname = "DescriptorProtos";
  42. option csharp_namespace = "Google.Protobuf.Reflection";
  43. option objc_class_prefix = "GPB";
  44. option cc_enable_arenas = true;
  45. // descriptor.proto must be optimized for speed because reflection-based
  46. // algorithms don't work during bootstrapping.
  47. option optimize_for = SPEED;
  48. // The protocol compiler can output a FileDescriptorSet containing the .proto
  49. // files it parses.
  50. message FileDescriptorSet {
  51. repeated FileDescriptorProto file = 1;
  52. }
  53. // Describes a complete .proto file.
  54. message FileDescriptorProto {
  55. optional string name = 1; // file name, relative to root of source tree
  56. optional string package = 2; // e.g. "foo", "foo.bar", etc.
  57. // Names of files imported by this file.
  58. repeated string dependency = 3;
  59. // Indexes of the public imported files in the dependency list above.
  60. repeated int32 public_dependency = 10;
  61. // Indexes of the weak imported files in the dependency list.
  62. // For Google-internal migration only. Do not use.
  63. repeated int32 weak_dependency = 11;
  64. // All top-level definitions in this file.
  65. repeated DescriptorProto message_type = 4;
  66. repeated EnumDescriptorProto enum_type = 5;
  67. repeated ServiceDescriptorProto service = 6;
  68. repeated FieldDescriptorProto extension = 7;
  69. optional FileOptions options = 8;
  70. // This field contains optional information about the original source code.
  71. // You may safely remove this entire field without harming runtime
  72. // functionality of the descriptors -- the information is needed only by
  73. // development tools.
  74. optional SourceCodeInfo source_code_info = 9;
  75. // The syntax of the proto file.
  76. // The supported values are "proto2" and "proto3".
  77. optional string syntax = 12;
  78. }
  79. // Describes a message type.
  80. message DescriptorProto {
  81. optional string name = 1;
  82. repeated FieldDescriptorProto field = 2;
  83. repeated FieldDescriptorProto extension = 6;
  84. repeated DescriptorProto nested_type = 3;
  85. repeated EnumDescriptorProto enum_type = 4;
  86. message ExtensionRange {
  87. optional int32 start = 1; // Inclusive.
  88. optional int32 end = 2; // Exclusive.
  89. optional ExtensionRangeOptions options = 3;
  90. }
  91. repeated ExtensionRange extension_range = 5;
  92. repeated OneofDescriptorProto oneof_decl = 8;
  93. optional MessageOptions options = 7;
  94. // Range of reserved tag numbers. Reserved tag numbers may not be used by
  95. // fields or extension ranges in the same message. Reserved ranges may
  96. // not overlap.
  97. message ReservedRange {
  98. optional int32 start = 1; // Inclusive.
  99. optional int32 end = 2; // Exclusive.
  100. }
  101. repeated ReservedRange reserved_range = 9;
  102. // Reserved field names, which may not be used by fields in the same message.
  103. // A given name may only be reserved once.
  104. repeated string reserved_name = 10;
  105. }
  106. message ExtensionRangeOptions {
  107. // The parser stores options it doesn't recognize here. See above.
  108. repeated UninterpretedOption uninterpreted_option = 999;
  109. // Clients can define custom options in extensions of this message. See above.
  110. extensions 1000 to max;
  111. }
  112. // Describes a field within a message.
  113. message FieldDescriptorProto {
  114. enum Type {
  115. // 0 is reserved for errors.
  116. // Order is weird for historical reasons.
  117. TYPE_DOUBLE = 1;
  118. TYPE_FLOAT = 2;
  119. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
  120. // negative values are likely.
  121. TYPE_INT64 = 3;
  122. TYPE_UINT64 = 4;
  123. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
  124. // negative values are likely.
  125. TYPE_INT32 = 5;
  126. TYPE_FIXED64 = 6;
  127. TYPE_FIXED32 = 7;
  128. TYPE_BOOL = 8;
  129. TYPE_STRING = 9;
  130. // Tag-delimited aggregate.
  131. // Group type is deprecated and not supported in proto3. However, Proto3
  132. // implementations should still be able to parse the group wire format and
  133. // treat group fields as unknown fields.
  134. TYPE_GROUP = 10;
  135. TYPE_MESSAGE = 11; // Length-delimited aggregate.
  136. // New in version 2.
  137. TYPE_BYTES = 12;
  138. TYPE_UINT32 = 13;
  139. TYPE_ENUM = 14;
  140. TYPE_SFIXED32 = 15;
  141. TYPE_SFIXED64 = 16;
  142. TYPE_SINT32 = 17; // Uses ZigZag encoding.
  143. TYPE_SINT64 = 18; // Uses ZigZag encoding.
  144. }
  145. enum Label {
  146. // 0 is reserved for errors
  147. LABEL_OPTIONAL = 1;
  148. LABEL_REQUIRED = 2;
  149. LABEL_REPEATED = 3;
  150. }
  151. optional string name = 1;
  152. optional int32 number = 3;
  153. optional Label label = 4;
  154. // If type_name is set, this need not be set. If both this and type_name
  155. // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
  156. optional Type type = 5;
  157. // For message and enum types, this is the name of the type. If the name
  158. // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
  159. // rules are used to find the type (i.e. first the nested types within this
  160. // message are searched, then within the parent, on up to the root
  161. // namespace).
  162. optional string type_name = 6;
  163. // For extensions, this is the name of the type being extended. It is
  164. // resolved in the same manner as type_name.
  165. optional string extendee = 2;
  166. // For numeric types, contains the original text representation of the value.
  167. // For booleans, "true" or "false".
  168. // For strings, contains the default text contents (not escaped in any way).
  169. // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
  170. optional string default_value = 7;
  171. // If set, gives the index of a oneof in the containing type's oneof_decl
  172. // list. This field is a member of that oneof.
  173. optional int32 oneof_index = 9;
  174. // JSON name of this field. The value is set by protocol compiler. If the
  175. // user has set a "json_name" option on this field, that option's value
  176. // will be used. Otherwise, it's deduced from the field's name by converting
  177. // it to camelCase.
  178. optional string json_name = 10;
  179. optional FieldOptions options = 8;
  180. // If true, this is a proto3 "optional". When a proto3 field is optional, it
  181. // tracks presence regardless of field type.
  182. //
  183. // When proto3_optional is true, this field must be belong to a oneof to
  184. // signal to old proto3 clients that presence is tracked for this field. This
  185. // oneof is known as a "synthetic" oneof, and this field must be its sole
  186. // member (each proto3 optional field gets its own synthetic oneof). Synthetic
  187. // oneofs exist in the descriptor only, and do not generate any API. Synthetic
  188. // oneofs must be ordered after all "real" oneofs.
  189. //
  190. // For message fields, proto3_optional doesn't create any semantic change,
  191. // since non-repeated message fields always track presence. However it still
  192. // indicates the semantic detail of whether the user wrote "optional" or not.
  193. // This can be useful for round-tripping the .proto file. For consistency we
  194. // give message fields a synthetic oneof also, even though it is not required
  195. // to track presence. This is especially important because the parser can't
  196. // tell if a field is a message or an enum, so it must always create a
  197. // synthetic oneof.
  198. //
  199. // Proto2 optional fields do not set this flag, because they already indicate
  200. // optional with `LABEL_OPTIONAL`.
  201. optional bool proto3_optional = 17;
  202. }
  203. // Describes a oneof.
  204. message OneofDescriptorProto {
  205. optional string name = 1;
  206. optional OneofOptions options = 2;
  207. }
  208. // Describes an enum type.
  209. message EnumDescriptorProto {
  210. optional string name = 1;
  211. repeated EnumValueDescriptorProto value = 2;
  212. optional EnumOptions options = 3;
  213. // Range of reserved numeric values. Reserved values may not be used by
  214. // entries in the same enum. Reserved ranges may not overlap.
  215. //
  216. // Note that this is distinct from DescriptorProto.ReservedRange in that it
  217. // is inclusive such that it can appropriately represent the entire int32
  218. // domain.
  219. message EnumReservedRange {
  220. optional int32 start = 1; // Inclusive.
  221. optional int32 end = 2; // Inclusive.
  222. }
  223. // Range of reserved numeric values. Reserved numeric values may not be used
  224. // by enum values in the same enum declaration. Reserved ranges may not
  225. // overlap.
  226. repeated EnumReservedRange reserved_range = 4;
  227. // Reserved enum value names, which may not be reused. A given name may only
  228. // be reserved once.
  229. repeated string reserved_name = 5;
  230. }
  231. // Describes a value within an enum.
  232. message EnumValueDescriptorProto {
  233. optional string name = 1;
  234. optional int32 number = 2;
  235. optional EnumValueOptions options = 3;
  236. }
  237. // Describes a service.
  238. message ServiceDescriptorProto {
  239. optional string name = 1;
  240. repeated MethodDescriptorProto method = 2;
  241. optional ServiceOptions options = 3;
  242. }
  243. // Describes a method of a service.
  244. message MethodDescriptorProto {
  245. optional string name = 1;
  246. // Input and output type names. These are resolved in the same way as
  247. // FieldDescriptorProto.type_name, but must refer to a message type.
  248. optional string input_type = 2;
  249. optional string output_type = 3;
  250. optional MethodOptions options = 4;
  251. // Identifies if client streams multiple client messages
  252. optional bool client_streaming = 5 [default = false];
  253. // Identifies if server streams multiple server messages
  254. optional bool server_streaming = 6 [default = false];
  255. }
  256. // ===================================================================
  257. // Options
  258. // Each of the definitions above may have "options" attached. These are
  259. // just annotations which may cause code to be generated slightly differently
  260. // or may contain hints for code that manipulates protocol messages.
  261. //
  262. // Clients may define custom options as extensions of the *Options messages.
  263. // These extensions may not yet be known at parsing time, so the parser cannot
  264. // store the values in them. Instead it stores them in a field in the *Options
  265. // message called uninterpreted_option. This field must have the same name
  266. // across all *Options messages. We then use this field to populate the
  267. // extensions when we build a descriptor, at which point all protos have been
  268. // parsed and so all extensions are known.
  269. //
  270. // Extension numbers for custom options may be chosen as follows:
  271. // * For options which will only be used within a single application or
  272. // organization, or for experimental options, use field numbers 50000
  273. // through 99999. It is up to you to ensure that you do not use the
  274. // same number for multiple options.
  275. // * For options which will be published and used publicly by multiple
  276. // independent entities, e-mail protobuf-global-extension-registry@google.com
  277. // to reserve extension numbers. Simply provide your project name (e.g.
  278. // Objective-C plugin) and your project website (if available) -- there's no
  279. // need to explain how you intend to use them. Usually you only need one
  280. // extension number. You can declare multiple options with only one extension
  281. // number by putting them in a sub-message. See the Custom Options section of
  282. // the docs for examples:
  283. // https://developers.google.com/protocol-buffers/docs/proto#options
  284. // If this turns out to be popular, a web service will be set up
  285. // to automatically assign option numbers.
  286. message FileOptions {
  287. // Sets the Java package where classes generated from this .proto will be
  288. // placed. By default, the proto package is used, but this is often
  289. // inappropriate because proto packages do not normally start with backwards
  290. // domain names.
  291. optional string java_package = 1;
  292. // Controls the name of the wrapper Java class generated for the .proto file.
  293. // That class will always contain the .proto file's getDescriptor() method as
  294. // well as any top-level extensions defined in the .proto file.
  295. // If java_multiple_files is disabled, then all the other classes from the
  296. // .proto file will be nested inside the single wrapper outer class.
  297. optional string java_outer_classname = 8;
  298. // If enabled, then the Java code generator will generate a separate .java
  299. // file for each top-level message, enum, and service defined in the .proto
  300. // file. Thus, these types will *not* be nested inside the wrapper class
  301. // named by java_outer_classname. However, the wrapper class will still be
  302. // generated to contain the file's getDescriptor() method as well as any
  303. // top-level extensions defined in the file.
  304. optional bool java_multiple_files = 10 [default = false];
  305. // This option does nothing.
  306. optional bool java_generate_equals_and_hash = 20 [deprecated=true];
  307. // If set true, then the Java2 code generator will generate code that
  308. // throws an exception whenever an attempt is made to assign a non-UTF-8
  309. // byte sequence to a string field.
  310. // Message reflection will do the same.
  311. // However, an extension field still accepts non-UTF-8 byte sequences.
  312. // This option has no effect on when used with the lite runtime.
  313. optional bool java_string_check_utf8 = 27 [default = false];
  314. // Generated classes can be optimized for speed or code size.
  315. enum OptimizeMode {
  316. SPEED = 1; // Generate complete code for parsing, serialization,
  317. // etc.
  318. CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
  319. LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
  320. }
  321. optional OptimizeMode optimize_for = 9 [default = SPEED];
  322. // Sets the Go package where structs generated from this .proto will be
  323. // placed. If omitted, the Go package will be derived from the following:
  324. // - The basename of the package import path, if provided.
  325. // - Otherwise, the package statement in the .proto file, if present.
  326. // - Otherwise, the basename of the .proto file, without extension.
  327. optional string go_package = 11;
  328. // Should generic services be generated in each language? "Generic" services
  329. // are not specific to any particular RPC system. They are generated by the
  330. // main code generators in each language (without additional plugins).
  331. // Generic services were the only kind of service generation supported by
  332. // early versions of google.protobuf.
  333. //
  334. // Generic services are now considered deprecated in favor of using plugins
  335. // that generate code specific to your particular RPC system. Therefore,
  336. // these default to false. Old code which depends on generic services should
  337. // explicitly set them to true.
  338. optional bool cc_generic_services = 16 [default = false];
  339. optional bool java_generic_services = 17 [default = false];
  340. optional bool py_generic_services = 18 [default = false];
  341. optional bool php_generic_services = 42 [default = false];
  342. // Is this file deprecated?
  343. // Depending on the target platform, this can emit Deprecated annotations
  344. // for everything in the file, or it will be completely ignored; in the very
  345. // least, this is a formalization for deprecating files.
  346. optional bool deprecated = 23 [default = false];
  347. // Enables the use of arenas for the proto messages in this file. This applies
  348. // only to generated classes for C++.
  349. optional bool cc_enable_arenas = 31 [default = true];
  350. // Sets the objective c class prefix which is prepended to all objective c
  351. // generated classes from this .proto. There is no default.
  352. optional string objc_class_prefix = 36;
  353. // Namespace for generated classes; defaults to the package.
  354. optional string csharp_namespace = 37;
  355. // By default Swift generators will take the proto package and CamelCase it
  356. // replacing '.' with underscore and use that to prefix the types/symbols
  357. // defined. When this options is provided, they will use this value instead
  358. // to prefix the types/symbols defined.
  359. optional string swift_prefix = 39;
  360. // Sets the php class prefix which is prepended to all php generated classes
  361. // from this .proto. Default is empty.
  362. optional string php_class_prefix = 40;
  363. // Use this option to change the namespace of php generated classes. Default
  364. // is empty. When this option is empty, the package name will be used for
  365. // determining the namespace.
  366. optional string php_namespace = 41;
  367. // Use this option to change the namespace of php generated metadata classes.
  368. // Default is empty. When this option is empty, the proto file name will be
  369. // used for determining the namespace.
  370. optional string php_metadata_namespace = 44;
  371. // Use this option to change the package of ruby generated classes. Default
  372. // is empty. When this option is not set, the package name will be used for
  373. // determining the ruby package.
  374. optional string ruby_package = 45;
  375. // The parser stores options it doesn't recognize here.
  376. // See the documentation for the "Options" section above.
  377. repeated UninterpretedOption uninterpreted_option = 999;
  378. // Clients can define custom options in extensions of this message.
  379. // See the documentation for the "Options" section above.
  380. extensions 1000 to max;
  381. reserved 38;
  382. }
  383. message MessageOptions {
  384. // Set true to use the old proto1 MessageSet wire format for extensions.
  385. // This is provided for backwards-compatibility with the MessageSet wire
  386. // format. You should not use this for any other reason: It's less
  387. // efficient, has fewer features, and is more complicated.
  388. //
  389. // The message must be defined exactly as follows:
  390. // message Foo {
  391. // option message_set_wire_format = true;
  392. // extensions 4 to max;
  393. // }
  394. // Note that the message cannot have any defined fields; MessageSets only
  395. // have extensions.
  396. //
  397. // All extensions of your type must be singular messages; e.g. they cannot
  398. // be int32s, enums, or repeated messages.
  399. //
  400. // Because this is an option, the above two restrictions are not enforced by
  401. // the protocol compiler.
  402. optional bool message_set_wire_format = 1 [default = false];
  403. // Disables the generation of the standard "descriptor()" accessor, which can
  404. // conflict with a field of the same name. This is meant to make migration
  405. // from proto1 easier; new code should avoid fields named "descriptor".
  406. optional bool no_standard_descriptor_accessor = 2 [default = false];
  407. // Is this message deprecated?
  408. // Depending on the target platform, this can emit Deprecated annotations
  409. // for the message, or it will be completely ignored; in the very least,
  410. // this is a formalization for deprecating messages.
  411. optional bool deprecated = 3 [default = false];
  412. reserved 4, 5, 6;
  413. // Whether the message is an automatically generated map entry type for the
  414. // maps field.
  415. //
  416. // For maps fields:
  417. // map<KeyType, ValueType> map_field = 1;
  418. // The parsed descriptor looks like:
  419. // message MapFieldEntry {
  420. // option map_entry = true;
  421. // optional KeyType key = 1;
  422. // optional ValueType value = 2;
  423. // }
  424. // repeated MapFieldEntry map_field = 1;
  425. //
  426. // Implementations may choose not to generate the map_entry=true message, but
  427. // use a native map in the target language to hold the keys and values.
  428. // The reflection APIs in such implementations still need to work as
  429. // if the field is a repeated message field.
  430. //
  431. // NOTE: Do not set the option in .proto files. Always use the maps syntax
  432. // instead. The option should only be implicitly set by the proto compiler
  433. // parser.
  434. optional bool map_entry = 7;
  435. reserved 8; // javalite_serializable
  436. reserved 9; // javanano_as_lite
  437. // The parser stores options it doesn't recognize here. See above.
  438. repeated UninterpretedOption uninterpreted_option = 999;
  439. // Clients can define custom options in extensions of this message. See above.
  440. extensions 1000 to max;
  441. }
  442. message FieldOptions {
  443. // The ctype option instructs the C++ code generator to use a different
  444. // representation of the field than it normally would. See the specific
  445. // options below. This option is not yet implemented in the open source
  446. // release -- sorry, we'll try to include it in a future version!
  447. optional CType ctype = 1 [default = STRING];
  448. enum CType {
  449. // Default mode.
  450. STRING = 0;
  451. CORD = 1;
  452. STRING_PIECE = 2;
  453. }
  454. // The packed option can be enabled for repeated primitive fields to enable
  455. // a more efficient representation on the wire. Rather than repeatedly
  456. // writing the tag and type for each element, the entire array is encoded as
  457. // a single length-delimited blob. In proto3, only explicit setting it to
  458. // false will avoid using packed encoding.
  459. optional bool packed = 2;
  460. // The jstype option determines the JavaScript type used for values of the
  461. // field. The option is permitted only for 64 bit integral and fixed types
  462. // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
  463. // is represented as JavaScript string, which avoids loss of precision that
  464. // can happen when a large value is converted to a floating point JavaScript.
  465. // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
  466. // use the JavaScript "number" type. The behavior of the default option
  467. // JS_NORMAL is implementation dependent.
  468. //
  469. // This option is an enum to permit additional types to be added, e.g.
  470. // goog.math.Integer.
  471. optional JSType jstype = 6 [default = JS_NORMAL];
  472. enum JSType {
  473. // Use the default type.
  474. JS_NORMAL = 0;
  475. // Use JavaScript strings.
  476. JS_STRING = 1;
  477. // Use JavaScript numbers.
  478. JS_NUMBER = 2;
  479. }
  480. // Should this field be parsed lazily? Lazy applies only to message-type
  481. // fields. It means that when the outer message is initially parsed, the
  482. // inner message's contents will not be parsed but instead stored in encoded
  483. // form. The inner message will actually be parsed when it is first accessed.
  484. //
  485. // This is only a hint. Implementations are free to choose whether to use
  486. // eager or lazy parsing regardless of the value of this option. However,
  487. // setting this option true suggests that the protocol author believes that
  488. // using lazy parsing on this field is worth the additional bookkeeping
  489. // overhead typically needed to implement it.
  490. //
  491. // This option does not affect the public interface of any generated code;
  492. // all method signatures remain the same. Furthermore, thread-safety of the
  493. // interface is not affected by this option; const methods remain safe to
  494. // call from multiple threads concurrently, while non-const methods continue
  495. // to require exclusive access.
  496. //
  497. //
  498. // Note that implementations may choose not to check required fields within
  499. // a lazy sub-message. That is, calling IsInitialized() on the outer message
  500. // may return true even if the inner message has missing required fields.
  501. // This is necessary because otherwise the inner message would have to be
  502. // parsed in order to perform the check, defeating the purpose of lazy
  503. // parsing. An implementation which chooses not to check required fields
  504. // must be consistent about it. That is, for any particular sub-message, the
  505. // implementation must either *always* check its required fields, or *never*
  506. // check its required fields, regardless of whether or not the message has
  507. // been parsed.
  508. //
  509. // As of 2021, lazy does no correctness checks on the byte stream during
  510. // parsing. This may lead to crashes if and when an invalid byte stream is
  511. // finally parsed upon access.
  512. //
  513. // TODO(b/211906113): Enable validation on lazy fields.
  514. optional bool lazy = 5 [default = false];
  515. // unverified_lazy does no correctness checks on the byte stream. This should
  516. // only be used where lazy with verification is prohibitive for performance
  517. // reasons.
  518. optional bool unverified_lazy = 15 [default = false];
  519. // Is this field deprecated?
  520. // Depending on the target platform, this can emit Deprecated annotations
  521. // for accessors, or it will be completely ignored; in the very least, this
  522. // is a formalization for deprecating fields.
  523. optional bool deprecated = 3 [default = false];
  524. // For Google-internal migration only. Do not use.
  525. optional bool weak = 10 [default = false];
  526. // The parser stores options it doesn't recognize here. See above.
  527. repeated UninterpretedOption uninterpreted_option = 999;
  528. // Clients can define custom options in extensions of this message. See above.
  529. extensions 1000 to max;
  530. reserved 4; // removed jtype
  531. }
  532. message OneofOptions {
  533. // The parser stores options it doesn't recognize here. See above.
  534. repeated UninterpretedOption uninterpreted_option = 999;
  535. // Clients can define custom options in extensions of this message. See above.
  536. extensions 1000 to max;
  537. }
  538. message EnumOptions {
  539. // Set this option to true to allow mapping different tag names to the same
  540. // value.
  541. optional bool allow_alias = 2;
  542. // Is this enum deprecated?
  543. // Depending on the target platform, this can emit Deprecated annotations
  544. // for the enum, or it will be completely ignored; in the very least, this
  545. // is a formalization for deprecating enums.
  546. optional bool deprecated = 3 [default = false];
  547. reserved 5; // javanano_as_lite
  548. // The parser stores options it doesn't recognize here. See above.
  549. repeated UninterpretedOption uninterpreted_option = 999;
  550. // Clients can define custom options in extensions of this message. See above.
  551. extensions 1000 to max;
  552. }
  553. message EnumValueOptions {
  554. // Is this enum value deprecated?
  555. // Depending on the target platform, this can emit Deprecated annotations
  556. // for the enum value, or it will be completely ignored; in the very least,
  557. // this is a formalization for deprecating enum values.
  558. optional bool deprecated = 1 [default = false];
  559. // The parser stores options it doesn't recognize here. See above.
  560. repeated UninterpretedOption uninterpreted_option = 999;
  561. // Clients can define custom options in extensions of this message. See above.
  562. extensions 1000 to max;
  563. }
  564. message ServiceOptions {
  565. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  566. // framework. We apologize for hoarding these numbers to ourselves, but
  567. // we were already using them long before we decided to release Protocol
  568. // Buffers.
  569. // Is this service deprecated?
  570. // Depending on the target platform, this can emit Deprecated annotations
  571. // for the service, or it will be completely ignored; in the very least,
  572. // this is a formalization for deprecating services.
  573. optional bool deprecated = 33 [default = false];
  574. // The parser stores options it doesn't recognize here. See above.
  575. repeated UninterpretedOption uninterpreted_option = 999;
  576. // Clients can define custom options in extensions of this message. See above.
  577. extensions 1000 to max;
  578. }
  579. message MethodOptions {
  580. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  581. // framework. We apologize for hoarding these numbers to ourselves, but
  582. // we were already using them long before we decided to release Protocol
  583. // Buffers.
  584. // Is this method deprecated?
  585. // Depending on the target platform, this can emit Deprecated annotations
  586. // for the method, or it will be completely ignored; in the very least,
  587. // this is a formalization for deprecating methods.
  588. optional bool deprecated = 33 [default = false];
  589. // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
  590. // or neither? HTTP based RPC implementation may choose GET verb for safe
  591. // methods, and PUT verb for idempotent methods instead of the default POST.
  592. enum IdempotencyLevel {
  593. IDEMPOTENCY_UNKNOWN = 0;
  594. NO_SIDE_EFFECTS = 1; // implies idempotent
  595. IDEMPOTENT = 2; // idempotent, but may have side effects
  596. }
  597. optional IdempotencyLevel idempotency_level = 34
  598. [default = IDEMPOTENCY_UNKNOWN];
  599. // The parser stores options it doesn't recognize here. See above.
  600. repeated UninterpretedOption uninterpreted_option = 999;
  601. // Clients can define custom options in extensions of this message. See above.
  602. extensions 1000 to max;
  603. }
  604. // A message representing a option the parser does not recognize. This only
  605. // appears in options protos created by the compiler::Parser class.
  606. // DescriptorPool resolves these when building Descriptor objects. Therefore,
  607. // options protos in descriptor objects (e.g. returned by Descriptor::options(),
  608. // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
  609. // in them.
  610. message UninterpretedOption {
  611. // The name of the uninterpreted option. Each string represents a segment in
  612. // a dot-separated name. is_extension is true iff a segment represents an
  613. // extension (denoted with parentheses in options specs in .proto files).
  614. // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
  615. // "foo.(bar.baz).moo".
  616. message NamePart {
  617. required string name_part = 1;
  618. required bool is_extension = 2;
  619. }
  620. repeated NamePart name = 2;
  621. // The value of the uninterpreted option, in whatever type the tokenizer
  622. // identified it as during parsing. Exactly one of these should be set.
  623. optional string identifier_value = 3;
  624. optional uint64 positive_int_value = 4;
  625. optional int64 negative_int_value = 5;
  626. optional double double_value = 6;
  627. optional bytes string_value = 7;
  628. optional string aggregate_value = 8;
  629. }
  630. // ===================================================================
  631. // Optional source code info
  632. // Encapsulates information about the original source file from which a
  633. // FileDescriptorProto was generated.
  634. message SourceCodeInfo {
  635. // A Location identifies a piece of source code in a .proto file which
  636. // corresponds to a particular definition. This information is intended
  637. // to be useful to IDEs, code indexers, documentation generators, and similar
  638. // tools.
  639. //
  640. // For example, say we have a file like:
  641. // message Foo {
  642. // optional string foo = 1;
  643. // }
  644. // Let's look at just the field definition:
  645. // optional string foo = 1;
  646. // ^ ^^ ^^ ^ ^^^
  647. // a bc de f ghi
  648. // We have the following locations:
  649. // span path represents
  650. // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
  651. // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
  652. // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
  653. // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
  654. // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
  655. //
  656. // Notes:
  657. // - A location may refer to a repeated field itself (i.e. not to any
  658. // particular index within it). This is used whenever a set of elements are
  659. // logically enclosed in a single code segment. For example, an entire
  660. // extend block (possibly containing multiple extension definitions) will
  661. // have an outer location whose path refers to the "extensions" repeated
  662. // field without an index.
  663. // - Multiple locations may have the same path. This happens when a single
  664. // logical declaration is spread out across multiple places. The most
  665. // obvious example is the "extend" block again -- there may be multiple
  666. // extend blocks in the same scope, each of which will have the same path.
  667. // - A location's span is not always a subset of its parent's span. For
  668. // example, the "extendee" of an extension declaration appears at the
  669. // beginning of the "extend" block and is shared by all extensions within
  670. // the block.
  671. // - Just because a location's span is a subset of some other location's span
  672. // does not mean that it is a descendant. For example, a "group" defines
  673. // both a type and a field in a single declaration. Thus, the locations
  674. // corresponding to the type and field and their components will overlap.
  675. // - Code which tries to interpret locations should probably be designed to
  676. // ignore those that it doesn't understand, as more types of locations could
  677. // be recorded in the future.
  678. repeated Location location = 1;
  679. message Location {
  680. // Identifies which part of the FileDescriptorProto was defined at this
  681. // location.
  682. //
  683. // Each element is a field number or an index. They form a path from
  684. // the root FileDescriptorProto to the place where the definition occurs.
  685. // For example, this path:
  686. // [ 4, 3, 2, 7, 1 ]
  687. // refers to:
  688. // file.message_type(3) // 4, 3
  689. // .field(7) // 2, 7
  690. // .name() // 1
  691. // This is because FileDescriptorProto.message_type has field number 4:
  692. // repeated DescriptorProto message_type = 4;
  693. // and DescriptorProto.field has field number 2:
  694. // repeated FieldDescriptorProto field = 2;
  695. // and FieldDescriptorProto.name has field number 1:
  696. // optional string name = 1;
  697. //
  698. // Thus, the above path gives the location of a field name. If we removed
  699. // the last element:
  700. // [ 4, 3, 2, 7 ]
  701. // this path refers to the whole field declaration (from the beginning
  702. // of the label to the terminating semicolon).
  703. repeated int32 path = 1 [packed = true];
  704. // Always has exactly three or four elements: start line, start column,
  705. // end line (optional, otherwise assumed same as start line), end column.
  706. // These are packed into a single field for efficiency. Note that line
  707. // and column numbers are zero-based -- typically you will want to add
  708. // 1 to each before displaying to a user.
  709. repeated int32 span = 2 [packed = true];
  710. // If this SourceCodeInfo represents a complete declaration, these are any
  711. // comments appearing before and after the declaration which appear to be
  712. // attached to the declaration.
  713. //
  714. // A series of line comments appearing on consecutive lines, with no other
  715. // tokens appearing on those lines, will be treated as a single comment.
  716. //
  717. // leading_detached_comments will keep paragraphs of comments that appear
  718. // before (but not connected to) the current element. Each paragraph,
  719. // separated by empty lines, will be one comment element in the repeated
  720. // field.
  721. //
  722. // Only the comment content is provided; comment markers (e.g. //) are
  723. // stripped out. For block comments, leading whitespace and an asterisk
  724. // will be stripped from the beginning of each line other than the first.
  725. // Newlines are included in the output.
  726. //
  727. // Examples:
  728. //
  729. // optional int32 foo = 1; // Comment attached to foo.
  730. // // Comment attached to bar.
  731. // optional int32 bar = 2;
  732. //
  733. // optional string baz = 3;
  734. // // Comment attached to baz.
  735. // // Another line attached to baz.
  736. //
  737. // // Comment attached to moo.
  738. // //
  739. // // Another line attached to moo.
  740. // optional double moo = 4;
  741. //
  742. // // Detached comment for corge. This is not leading or trailing comments
  743. // // to moo or corge because there are blank lines separating it from
  744. // // both.
  745. //
  746. // // Detached comment for corge paragraph 2.
  747. //
  748. // optional string corge = 5;
  749. // /* Block comment attached
  750. // * to corge. Leading asterisks
  751. // * will be removed. */
  752. // /* Block comment attached to
  753. // * grault. */
  754. // optional int32 grault = 6;
  755. //
  756. // // ignored detached comments.
  757. optional string leading_comments = 3;
  758. optional string trailing_comments = 4;
  759. repeated string leading_detached_comments = 6;
  760. }
  761. }
  762. // Describes the relationship between generated code and its original source
  763. // file. A GeneratedCodeInfo message is associated with only one generated
  764. // source file, but may contain references to different source .proto files.
  765. message GeneratedCodeInfo {
  766. // An Annotation connects some span of text in generated code to an element
  767. // of its generating .proto file.
  768. repeated Annotation annotation = 1;
  769. message Annotation {
  770. // Identifies the element in the original source .proto file. This field
  771. // is formatted the same as SourceCodeInfo.Location.path.
  772. repeated int32 path = 1 [packed = true];
  773. // Identifies the filesystem path to the original source .proto.
  774. optional string source_file = 2;
  775. // Identifies the starting offset in bytes in the generated code
  776. // that relates to the identified object.
  777. optional int32 begin = 3;
  778. // Identifies the ending offset in bytes in the generated code that
  779. // relates to the identified offset. The end offset should be one past
  780. // the last relevant byte (so the length of the text = end - begin).
  781. optional int32 end = 4;
  782. }
  783. }