descriptor.proto 40 KB

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