descriptor.proto 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417
  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. // Extensions for tooling.
  53. extensions 536000000 [declaration = {
  54. number: 536000000
  55. type: ".buf.descriptor.v1.FileDescriptorSetExtension"
  56. full_name: ".buf.descriptor.v1.buf_file_descriptor_set_extension"
  57. }];
  58. }
  59. // The full set of known editions.
  60. enum Edition {
  61. // A placeholder for an unknown edition value.
  62. EDITION_UNKNOWN = 0;
  63. // A placeholder edition for specifying default behaviors *before* a feature
  64. // was first introduced. This is effectively an "infinite past".
  65. EDITION_LEGACY = 900;
  66. // Legacy syntax "editions". These pre-date editions, but behave much like
  67. // distinct editions. These can't be used to specify the edition of proto
  68. // files, but feature definitions must supply proto2/proto3 defaults for
  69. // backwards compatibility.
  70. EDITION_PROTO2 = 998;
  71. EDITION_PROTO3 = 999;
  72. // Editions that have been released. The specific values are arbitrary and
  73. // should not be depended on, but they will always be time-ordered for easy
  74. // comparison.
  75. EDITION_2023 = 1000;
  76. EDITION_2024 = 1001;
  77. // Placeholder editions for testing feature resolution. These should not be
  78. // used or relied on outside of tests.
  79. EDITION_1_TEST_ONLY = 1;
  80. EDITION_2_TEST_ONLY = 2;
  81. EDITION_99997_TEST_ONLY = 99997;
  82. EDITION_99998_TEST_ONLY = 99998;
  83. EDITION_99999_TEST_ONLY = 99999;
  84. // Placeholder for specifying unbounded edition support. This should only
  85. // ever be used by plugins that can expect to never require any changes to
  86. // support a new edition.
  87. EDITION_MAX = 0x7FFFFFFF;
  88. }
  89. // Describes a complete .proto file.
  90. message FileDescriptorProto {
  91. optional string name = 1; // file name, relative to root of source tree
  92. optional string package = 2; // e.g. "foo", "foo.bar", etc.
  93. // Names of files imported by this file.
  94. repeated string dependency = 3;
  95. // Indexes of the public imported files in the dependency list above.
  96. repeated int32 public_dependency = 10;
  97. // Indexes of the weak imported files in the dependency list.
  98. // For Google-internal migration only. Do not use.
  99. repeated int32 weak_dependency = 11;
  100. // Names of files imported by this file purely for the purpose of providing
  101. // option extensions. These are excluded from the dependency list above.
  102. repeated string option_dependency = 15;
  103. // All top-level definitions in this file.
  104. repeated DescriptorProto message_type = 4;
  105. repeated EnumDescriptorProto enum_type = 5;
  106. repeated ServiceDescriptorProto service = 6;
  107. repeated FieldDescriptorProto extension = 7;
  108. optional FileOptions options = 8;
  109. // This field contains optional information about the original source code.
  110. // You may safely remove this entire field without harming runtime
  111. // functionality of the descriptors -- the information is needed only by
  112. // development tools.
  113. optional SourceCodeInfo source_code_info = 9;
  114. // The syntax of the proto file.
  115. // The supported values are "proto2", "proto3", and "editions".
  116. //
  117. // If `edition` is present, this value must be "editions".
  118. // WARNING: This field should only be used by protobuf plugins or special
  119. // cases like the proto compiler. Other uses are discouraged and
  120. // developers should rely on the protoreflect APIs for their client language.
  121. optional string syntax = 12;
  122. // The edition of the proto file.
  123. // WARNING: This field should only be used by protobuf plugins or special
  124. // cases like the proto compiler. Other uses are discouraged and
  125. // developers should rely on the protoreflect APIs for their client language.
  126. optional Edition edition = 14;
  127. }
  128. // Describes a message type.
  129. message DescriptorProto {
  130. optional string name = 1;
  131. repeated FieldDescriptorProto field = 2;
  132. repeated FieldDescriptorProto extension = 6;
  133. repeated DescriptorProto nested_type = 3;
  134. repeated EnumDescriptorProto enum_type = 4;
  135. message ExtensionRange {
  136. optional int32 start = 1; // Inclusive.
  137. optional int32 end = 2; // Exclusive.
  138. optional ExtensionRangeOptions options = 3;
  139. }
  140. repeated ExtensionRange extension_range = 5;
  141. repeated OneofDescriptorProto oneof_decl = 8;
  142. optional MessageOptions options = 7;
  143. // Range of reserved tag numbers. Reserved tag numbers may not be used by
  144. // fields or extension ranges in the same message. Reserved ranges may
  145. // not overlap.
  146. message ReservedRange {
  147. optional int32 start = 1; // Inclusive.
  148. optional int32 end = 2; // Exclusive.
  149. }
  150. repeated ReservedRange reserved_range = 9;
  151. // Reserved field names, which may not be used by fields in the same message.
  152. // A given name may only be reserved once.
  153. repeated string reserved_name = 10;
  154. // Support for `export` and `local` keywords on enums.
  155. optional SymbolVisibility visibility = 11;
  156. }
  157. message ExtensionRangeOptions {
  158. // The parser stores options it doesn't recognize here. See above.
  159. repeated UninterpretedOption uninterpreted_option = 999;
  160. message Declaration {
  161. // The extension number declared within the extension range.
  162. optional int32 number = 1;
  163. // The fully-qualified name of the extension field. There must be a leading
  164. // dot in front of the full name.
  165. optional string full_name = 2;
  166. // The fully-qualified type name of the extension field. Unlike
  167. // Metadata.type, Declaration.type must have a leading dot for messages
  168. // and enums.
  169. optional string type = 3;
  170. // If true, indicates that the number is reserved in the extension range,
  171. // and any extension field with the number will fail to compile. Set this
  172. // when a declared extension field is deleted.
  173. optional bool reserved = 5;
  174. // If true, indicates that the extension must be defined as repeated.
  175. // Otherwise the extension must be defined as optional.
  176. optional bool repeated = 6;
  177. reserved 4; // removed is_repeated
  178. }
  179. // For external users: DO NOT USE. We are in the process of open sourcing
  180. // extension declaration and executing internal cleanups before it can be
  181. // used externally.
  182. repeated Declaration declaration = 2 [retention = RETENTION_SOURCE];
  183. // Any features defined in the specific edition.
  184. optional FeatureSet features = 50;
  185. // The verification state of the extension range.
  186. enum VerificationState {
  187. // All the extensions of the range must be declared.
  188. DECLARATION = 0;
  189. UNVERIFIED = 1;
  190. }
  191. // The verification state of the range.
  192. // TODO: flip the default to DECLARATION once all empty ranges
  193. // are marked as UNVERIFIED.
  194. optional VerificationState verification = 3
  195. [default = UNVERIFIED, retention = RETENTION_SOURCE];
  196. // Clients can define custom options in extensions of this message. See above.
  197. extensions 1000 to max;
  198. }
  199. // Describes a field within a message.
  200. message FieldDescriptorProto {
  201. enum Type {
  202. // 0 is reserved for errors.
  203. // Order is weird for historical reasons.
  204. TYPE_DOUBLE = 1;
  205. TYPE_FLOAT = 2;
  206. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
  207. // negative values are likely.
  208. TYPE_INT64 = 3;
  209. TYPE_UINT64 = 4;
  210. // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
  211. // negative values are likely.
  212. TYPE_INT32 = 5;
  213. TYPE_FIXED64 = 6;
  214. TYPE_FIXED32 = 7;
  215. TYPE_BOOL = 8;
  216. TYPE_STRING = 9;
  217. // Tag-delimited aggregate.
  218. // Group type is deprecated and not supported after google.protobuf. However, Proto3
  219. // implementations should still be able to parse the group wire format and
  220. // treat group fields as unknown fields. In Editions, the group wire format
  221. // can be enabled via the `message_encoding` feature.
  222. TYPE_GROUP = 10;
  223. TYPE_MESSAGE = 11; // Length-delimited aggregate.
  224. // New in version 2.
  225. TYPE_BYTES = 12;
  226. TYPE_UINT32 = 13;
  227. TYPE_ENUM = 14;
  228. TYPE_SFIXED32 = 15;
  229. TYPE_SFIXED64 = 16;
  230. TYPE_SINT32 = 17; // Uses ZigZag encoding.
  231. TYPE_SINT64 = 18; // Uses ZigZag encoding.
  232. }
  233. enum Label {
  234. // 0 is reserved for errors
  235. LABEL_OPTIONAL = 1;
  236. LABEL_REPEATED = 3;
  237. // The required label is only allowed in google.protobuf. In proto3 and Editions
  238. // it's explicitly prohibited. In Editions, the `field_presence` feature
  239. // can be used to get this behavior.
  240. LABEL_REQUIRED = 2;
  241. }
  242. optional string name = 1;
  243. optional int32 number = 3;
  244. optional Label label = 4;
  245. // If type_name is set, this need not be set. If both this and type_name
  246. // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
  247. optional Type type = 5;
  248. // For message and enum types, this is the name of the type. If the name
  249. // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
  250. // rules are used to find the type (i.e. first the nested types within this
  251. // message are searched, then within the parent, on up to the root
  252. // namespace).
  253. optional string type_name = 6;
  254. // For extensions, this is the name of the type being extended. It is
  255. // resolved in the same manner as type_name.
  256. optional string extendee = 2;
  257. // For numeric types, contains the original text representation of the value.
  258. // For booleans, "true" or "false".
  259. // For strings, contains the default text contents (not escaped in any way).
  260. // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
  261. optional string default_value = 7;
  262. // If set, gives the index of a oneof in the containing type's oneof_decl
  263. // list. This field is a member of that oneof.
  264. optional int32 oneof_index = 9;
  265. // JSON name of this field. The value is set by protocol compiler. If the
  266. // user has set a "json_name" option on this field, that option's value
  267. // will be used. Otherwise, it's deduced from the field's name by converting
  268. // it to camelCase.
  269. optional string json_name = 10;
  270. optional FieldOptions options = 8;
  271. // If true, this is a proto3 "optional". When a proto3 field is optional, it
  272. // tracks presence regardless of field type.
  273. //
  274. // When proto3_optional is true, this field must belong to a oneof to signal
  275. // to old proto3 clients that presence is tracked for this field. This oneof
  276. // is known as a "synthetic" oneof, and this field must be its sole member
  277. // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
  278. // exist in the descriptor only, and do not generate any API. Synthetic oneofs
  279. // must be ordered after all "real" oneofs.
  280. //
  281. // For message fields, proto3_optional doesn't create any semantic change,
  282. // since non-repeated message fields always track presence. However it still
  283. // indicates the semantic detail of whether the user wrote "optional" or not.
  284. // This can be useful for round-tripping the .proto file. For consistency we
  285. // give message fields a synthetic oneof also, even though it is not required
  286. // to track presence. This is especially important because the parser can't
  287. // tell if a field is a message or an enum, so it must always create a
  288. // synthetic oneof.
  289. //
  290. // Proto2 optional fields do not set this flag, because they already indicate
  291. // optional with `LABEL_OPTIONAL`.
  292. optional bool proto3_optional = 17;
  293. }
  294. // Describes a oneof.
  295. message OneofDescriptorProto {
  296. optional string name = 1;
  297. optional OneofOptions options = 2;
  298. }
  299. // Describes an enum type.
  300. message EnumDescriptorProto {
  301. optional string name = 1;
  302. repeated EnumValueDescriptorProto value = 2;
  303. optional EnumOptions options = 3;
  304. // Range of reserved numeric values. Reserved values may not be used by
  305. // entries in the same enum. Reserved ranges may not overlap.
  306. //
  307. // Note that this is distinct from DescriptorProto.ReservedRange in that it
  308. // is inclusive such that it can appropriately represent the entire int32
  309. // domain.
  310. message EnumReservedRange {
  311. optional int32 start = 1; // Inclusive.
  312. optional int32 end = 2; // Inclusive.
  313. }
  314. // Range of reserved numeric values. Reserved numeric values may not be used
  315. // by enum values in the same enum declaration. Reserved ranges may not
  316. // overlap.
  317. repeated EnumReservedRange reserved_range = 4;
  318. // Reserved enum value names, which may not be reused. A given name may only
  319. // be reserved once.
  320. repeated string reserved_name = 5;
  321. // Support for `export` and `local` keywords on enums.
  322. optional SymbolVisibility visibility = 6;
  323. }
  324. // Describes a value within an enum.
  325. message EnumValueDescriptorProto {
  326. optional string name = 1;
  327. optional int32 number = 2;
  328. optional EnumValueOptions options = 3;
  329. }
  330. // Describes a service.
  331. message ServiceDescriptorProto {
  332. optional string name = 1;
  333. repeated MethodDescriptorProto method = 2;
  334. optional ServiceOptions options = 3;
  335. }
  336. // Describes a method of a service.
  337. message MethodDescriptorProto {
  338. optional string name = 1;
  339. // Input and output type names. These are resolved in the same way as
  340. // FieldDescriptorProto.type_name, but must refer to a message type.
  341. optional string input_type = 2;
  342. optional string output_type = 3;
  343. optional MethodOptions options = 4;
  344. // Identifies if client streams multiple client messages
  345. optional bool client_streaming = 5 [default = false];
  346. // Identifies if server streams multiple server messages
  347. optional bool server_streaming = 6 [default = false];
  348. }
  349. // ===================================================================
  350. // Options
  351. // Each of the definitions above may have "options" attached. These are
  352. // just annotations which may cause code to be generated slightly differently
  353. // or may contain hints for code that manipulates protocol messages.
  354. //
  355. // Clients may define custom options as extensions of the *Options messages.
  356. // These extensions may not yet be known at parsing time, so the parser cannot
  357. // store the values in them. Instead it stores them in a field in the *Options
  358. // message called uninterpreted_option. This field must have the same name
  359. // across all *Options messages. We then use this field to populate the
  360. // extensions when we build a descriptor, at which point all protos have been
  361. // parsed and so all extensions are known.
  362. //
  363. // Extension numbers for custom options may be chosen as follows:
  364. // * For options which will only be used within a single application or
  365. // organization, or for experimental options, use field numbers 50000
  366. // through 99999. It is up to you to ensure that you do not use the
  367. // same number for multiple options.
  368. // * For options which will be published and used publicly by multiple
  369. // independent entities, e-mail protobuf-global-extension-registry@google.com
  370. // to reserve extension numbers. Simply provide your project name (e.g.
  371. // Objective-C plugin) and your project website (if available) -- there's no
  372. // need to explain how you intend to use them. Usually you only need one
  373. // extension number. You can declare multiple options with only one extension
  374. // number by putting them in a sub-message. See the Custom Options section of
  375. // the docs for examples:
  376. // https://developers.google.com/protocol-buffers/docs/proto#options
  377. // If this turns out to be popular, a web service will be set up
  378. // to automatically assign option numbers.
  379. message FileOptions {
  380. // Sets the Java package where classes generated from this .proto will be
  381. // placed. By default, the proto package is used, but this is often
  382. // inappropriate because proto packages do not normally start with backwards
  383. // domain names.
  384. optional string java_package = 1;
  385. // Controls the name of the wrapper Java class generated for the .proto file.
  386. // That class will always contain the .proto file's getDescriptor() method as
  387. // well as any top-level extensions defined in the .proto file.
  388. // If java_multiple_files is disabled, then all the other classes from the
  389. // .proto file will be nested inside the single wrapper outer class.
  390. optional string java_outer_classname = 8;
  391. // If enabled, then the Java code generator will generate a separate .java
  392. // file for each top-level message, enum, and service defined in the .proto
  393. // file. Thus, these types will *not* be nested inside the wrapper class
  394. // named by java_outer_classname. However, the wrapper class will still be
  395. // generated to contain the file's getDescriptor() method as well as any
  396. // top-level extensions defined in the file.
  397. optional bool java_multiple_files = 10 [default = false];
  398. // This option does nothing.
  399. optional bool java_generate_equals_and_hash = 20 [deprecated=true];
  400. // A proto2 file can set this to true to opt in to UTF-8 checking for Java,
  401. // which will throw an exception if invalid UTF-8 is parsed from the wire or
  402. // assigned to a string field.
  403. //
  404. // TODO: clarify exactly what kinds of field types this option
  405. // applies to, and update these docs accordingly.
  406. //
  407. // Proto3 files already perform these checks. Setting the option explicitly to
  408. // false has no effect: it cannot be used to opt proto3 files out of UTF-8
  409. // checks.
  410. optional bool java_string_check_utf8 = 27 [default = false];
  411. // Generated classes can be optimized for speed or code size.
  412. enum OptimizeMode {
  413. SPEED = 1; // Generate complete code for parsing, serialization,
  414. // etc.
  415. CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
  416. LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
  417. }
  418. optional OptimizeMode optimize_for = 9 [default = SPEED];
  419. // Sets the Go package where structs generated from this .proto will be
  420. // placed. If omitted, the Go package will be derived from the following:
  421. // - The basename of the package import path, if provided.
  422. // - Otherwise, the package statement in the .proto file, if present.
  423. // - Otherwise, the basename of the .proto file, without extension.
  424. optional string go_package = 11;
  425. // Should generic services be generated in each language? "Generic" services
  426. // are not specific to any particular RPC system. They are generated by the
  427. // main code generators in each language (without additional plugins).
  428. // Generic services were the only kind of service generation supported by
  429. // early versions of google.protobuf.
  430. //
  431. // Generic services are now considered deprecated in favor of using plugins
  432. // that generate code specific to your particular RPC system. Therefore,
  433. // these default to false. Old code which depends on generic services should
  434. // explicitly set them to true.
  435. optional bool cc_generic_services = 16 [default = false];
  436. optional bool java_generic_services = 17 [default = false];
  437. optional bool py_generic_services = 18 [default = false];
  438. reserved 42; // removed php_generic_services
  439. reserved "php_generic_services";
  440. // Is this file deprecated?
  441. // Depending on the target platform, this can emit Deprecated annotations
  442. // for everything in the file, or it will be completely ignored; in the very
  443. // least, this is a formalization for deprecating files.
  444. optional bool deprecated = 23 [default = false];
  445. // Enables the use of arenas for the proto messages in this file. This applies
  446. // only to generated classes for C++.
  447. optional bool cc_enable_arenas = 31 [default = true];
  448. // Sets the objective c class prefix which is prepended to all objective c
  449. // generated classes from this .proto. There is no default.
  450. optional string objc_class_prefix = 36;
  451. // Namespace for generated classes; defaults to the package.
  452. optional string csharp_namespace = 37;
  453. // By default Swift generators will take the proto package and CamelCase it
  454. // replacing '.' with underscore and use that to prefix the types/symbols
  455. // defined. When this options is provided, they will use this value instead
  456. // to prefix the types/symbols defined.
  457. optional string swift_prefix = 39;
  458. // Sets the php class prefix which is prepended to all php generated classes
  459. // from this .proto. Default is empty.
  460. optional string php_class_prefix = 40;
  461. // Use this option to change the namespace of php generated classes. Default
  462. // is empty. When this option is empty, the package name will be used for
  463. // determining the namespace.
  464. optional string php_namespace = 41;
  465. // Use this option to change the namespace of php generated metadata classes.
  466. // Default is empty. When this option is empty, the proto file name will be
  467. // used for determining the namespace.
  468. optional string php_metadata_namespace = 44;
  469. // Use this option to change the package of ruby generated classes. Default
  470. // is empty. When this option is not set, the package name will be used for
  471. // determining the ruby package.
  472. optional string ruby_package = 45;
  473. // Any features defined in the specific edition.
  474. // WARNING: This field should only be used by protobuf plugins or special
  475. // cases like the proto compiler. Other uses are discouraged and
  476. // developers should rely on the protoreflect APIs for their client language.
  477. optional FeatureSet features = 50;
  478. // The parser stores options it doesn't recognize here.
  479. // See the documentation for the "Options" section above.
  480. repeated UninterpretedOption uninterpreted_option = 999;
  481. // Clients can define custom options in extensions of this message.
  482. // See the documentation for the "Options" section above.
  483. extensions 1000 to max;
  484. reserved 38;
  485. }
  486. message MessageOptions {
  487. // Set true to use the old proto1 MessageSet wire format for extensions.
  488. // This is provided for backwards-compatibility with the MessageSet wire
  489. // format. You should not use this for any other reason: It's less
  490. // efficient, has fewer features, and is more complicated.
  491. //
  492. // The message must be defined exactly as follows:
  493. // message Foo {
  494. // option message_set_wire_format = true;
  495. // extensions 4 to max;
  496. // }
  497. // Note that the message cannot have any defined fields; MessageSets only
  498. // have extensions.
  499. //
  500. // All extensions of your type must be singular messages; e.g. they cannot
  501. // be int32s, enums, or repeated messages.
  502. //
  503. // Because this is an option, the above two restrictions are not enforced by
  504. // the protocol compiler.
  505. optional bool message_set_wire_format = 1 [default = false];
  506. // Disables the generation of the standard "descriptor()" accessor, which can
  507. // conflict with a field of the same name. This is meant to make migration
  508. // from proto1 easier; new code should avoid fields named "descriptor".
  509. optional bool no_standard_descriptor_accessor = 2 [default = false];
  510. // Is this message deprecated?
  511. // Depending on the target platform, this can emit Deprecated annotations
  512. // for the message, or it will be completely ignored; in the very least,
  513. // this is a formalization for deprecating messages.
  514. optional bool deprecated = 3 [default = false];
  515. reserved 4, 5, 6;
  516. // Whether the message is an automatically generated map entry type for the
  517. // maps field.
  518. //
  519. // For maps fields:
  520. // map<KeyType, ValueType> map_field = 1;
  521. // The parsed descriptor looks like:
  522. // message MapFieldEntry {
  523. // option map_entry = true;
  524. // optional KeyType key = 1;
  525. // optional ValueType value = 2;
  526. // }
  527. // repeated MapFieldEntry map_field = 1;
  528. //
  529. // Implementations may choose not to generate the map_entry=true message, but
  530. // use a native map in the target language to hold the keys and values.
  531. // The reflection APIs in such implementations still need to work as
  532. // if the field is a repeated message field.
  533. //
  534. // NOTE: Do not set the option in .proto files. Always use the maps syntax
  535. // instead. The option should only be implicitly set by the proto compiler
  536. // parser.
  537. optional bool map_entry = 7;
  538. reserved 8; // javalite_serializable
  539. reserved 9; // javanano_as_lite
  540. // Enable the legacy handling of JSON field name conflicts. This lowercases
  541. // and strips underscored from the fields before comparison in proto3 only.
  542. // The new behavior takes `json_name` into account and applies to proto2 as
  543. // well.
  544. //
  545. // This should only be used as a temporary measure against broken builds due
  546. // to the change in behavior for JSON field name conflicts.
  547. //
  548. // TODO This is legacy behavior we plan to remove once downstream
  549. // teams have had time to migrate.
  550. optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
  551. // Any features defined in the specific edition.
  552. // WARNING: This field should only be used by protobuf plugins or special
  553. // cases like the proto compiler. Other uses are discouraged and
  554. // developers should rely on the protoreflect APIs for their client language.
  555. optional FeatureSet features = 12;
  556. // The parser stores options it doesn't recognize here. See above.
  557. repeated UninterpretedOption uninterpreted_option = 999;
  558. // Clients can define custom options in extensions of this message. See above.
  559. extensions 1000 to max;
  560. }
  561. message FieldOptions {
  562. // NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
  563. // The ctype option instructs the C++ code generator to use a different
  564. // representation of the field than it normally would. See the specific
  565. // options below. This option is only implemented to support use of
  566. // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
  567. // type "bytes" in the open source release.
  568. // TODO: make ctype actually deprecated.
  569. optional CType ctype = 1 [/*deprecated = true,*/ default = STRING];
  570. enum CType {
  571. // Default mode.
  572. STRING = 0;
  573. // The option [ctype=CORD] may be applied to a non-repeated field of type
  574. // "bytes". It indicates that in C++, the data should be stored in a Cord
  575. // instead of a string. For very large strings, this may reduce memory
  576. // fragmentation. It may also allow better performance when parsing from a
  577. // Cord, or when parsing with aliasing enabled, as the parsed Cord may then
  578. // alias the original buffer.
  579. CORD = 1;
  580. STRING_PIECE = 2;
  581. }
  582. // The packed option can be enabled for repeated primitive fields to enable
  583. // a more efficient representation on the wire. Rather than repeatedly
  584. // writing the tag and type for each element, the entire array is encoded as
  585. // a single length-delimited blob. In proto3, only explicit setting it to
  586. // false will avoid using packed encoding. This option is prohibited in
  587. // Editions, but the `repeated_field_encoding` feature can be used to control
  588. // the behavior.
  589. optional bool packed = 2;
  590. // The jstype option determines the JavaScript type used for values of the
  591. // field. The option is permitted only for 64 bit integral and fixed types
  592. // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
  593. // is represented as JavaScript string, which avoids loss of precision that
  594. // can happen when a large value is converted to a floating point JavaScript.
  595. // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
  596. // use the JavaScript "number" type. The behavior of the default option
  597. // JS_NORMAL is implementation dependent.
  598. //
  599. // This option is an enum to permit additional types to be added, e.g.
  600. // goog.math.Integer.
  601. optional JSType jstype = 6 [default = JS_NORMAL];
  602. enum JSType {
  603. // Use the default type.
  604. JS_NORMAL = 0;
  605. // Use JavaScript strings.
  606. JS_STRING = 1;
  607. // Use JavaScript numbers.
  608. JS_NUMBER = 2;
  609. }
  610. // Should this field be parsed lazily? Lazy applies only to message-type
  611. // fields. It means that when the outer message is initially parsed, the
  612. // inner message's contents will not be parsed but instead stored in encoded
  613. // form. The inner message will actually be parsed when it is first accessed.
  614. //
  615. // This is only a hint. Implementations are free to choose whether to use
  616. // eager or lazy parsing regardless of the value of this option. However,
  617. // setting this option true suggests that the protocol author believes that
  618. // using lazy parsing on this field is worth the additional bookkeeping
  619. // overhead typically needed to implement it.
  620. //
  621. // This option does not affect the public interface of any generated code;
  622. // all method signatures remain the same. Furthermore, thread-safety of the
  623. // interface is not affected by this option; const methods remain safe to
  624. // call from multiple threads concurrently, while non-const methods continue
  625. // to require exclusive access.
  626. //
  627. // Note that lazy message fields are still eagerly verified to check
  628. // ill-formed wireformat or missing required fields. Calling IsInitialized()
  629. // on the outer message would fail if the inner message has missing required
  630. // fields. Failed verification would result in parsing failure (except when
  631. // uninitialized messages are acceptable).
  632. optional bool lazy = 5 [default = false];
  633. // unverified_lazy does no correctness checks on the byte stream. This should
  634. // only be used where lazy with verification is prohibitive for performance
  635. // reasons.
  636. optional bool unverified_lazy = 15 [default = false];
  637. // Is this field deprecated?
  638. // Depending on the target platform, this can emit Deprecated annotations
  639. // for accessors, or it will be completely ignored; in the very least, this
  640. // is a formalization for deprecating fields.
  641. optional bool deprecated = 3 [default = false];
  642. // For Google-internal migration only. Do not use.
  643. optional bool weak = 10 [default = false];
  644. // Indicate that the field value should not be printed out when using debug
  645. // formats, e.g. when the field contains sensitive credentials.
  646. optional bool debug_redact = 16 [default = false];
  647. // If set to RETENTION_SOURCE, the option will be omitted from the binary.
  648. enum OptionRetention {
  649. RETENTION_UNKNOWN = 0;
  650. RETENTION_RUNTIME = 1;
  651. RETENTION_SOURCE = 2;
  652. }
  653. optional OptionRetention retention = 17;
  654. // This indicates the types of entities that the field may apply to when used
  655. // as an option. If it is unset, then the field may be freely used as an
  656. // option on any kind of entity.
  657. enum OptionTargetType {
  658. TARGET_TYPE_UNKNOWN = 0;
  659. TARGET_TYPE_FILE = 1;
  660. TARGET_TYPE_EXTENSION_RANGE = 2;
  661. TARGET_TYPE_MESSAGE = 3;
  662. TARGET_TYPE_FIELD = 4;
  663. TARGET_TYPE_ONEOF = 5;
  664. TARGET_TYPE_ENUM = 6;
  665. TARGET_TYPE_ENUM_ENTRY = 7;
  666. TARGET_TYPE_SERVICE = 8;
  667. TARGET_TYPE_METHOD = 9;
  668. }
  669. repeated OptionTargetType targets = 19;
  670. message EditionDefault {
  671. optional Edition edition = 3;
  672. optional string value = 2; // Textproto value.
  673. }
  674. repeated EditionDefault edition_defaults = 20;
  675. // Any features defined in the specific edition.
  676. // WARNING: This field should only be used by protobuf plugins or special
  677. // cases like the proto compiler. Other uses are discouraged and
  678. // developers should rely on the protoreflect APIs for their client language.
  679. optional FeatureSet features = 21;
  680. // Information about the support window of a feature.
  681. message FeatureSupport {
  682. // The edition that this feature was first available in. In editions
  683. // earlier than this one, the default assigned to EDITION_LEGACY will be
  684. // used, and proto files will not be able to override it.
  685. optional Edition edition_introduced = 1;
  686. // The edition this feature becomes deprecated in. Using this after this
  687. // edition may trigger warnings.
  688. optional Edition edition_deprecated = 2;
  689. // The deprecation warning text if this feature is used after the edition it
  690. // was marked deprecated in.
  691. optional string deprecation_warning = 3;
  692. // The edition this feature is no longer available in. In editions after
  693. // this one, the last default assigned will be used, and proto files will
  694. // not be able to override it.
  695. optional Edition edition_removed = 4;
  696. }
  697. optional FeatureSupport feature_support = 22;
  698. // The parser stores options it doesn't recognize here. See above.
  699. repeated UninterpretedOption uninterpreted_option = 999;
  700. // Clients can define custom options in extensions of this message. See above.
  701. extensions 1000 to max;
  702. reserved 4; // removed jtype
  703. reserved 18; // reserve target, target_obsolete_do_not_use
  704. }
  705. message OneofOptions {
  706. // Any features defined in the specific edition.
  707. // WARNING: This field should only be used by protobuf plugins or special
  708. // cases like the proto compiler. Other uses are discouraged and
  709. // developers should rely on the protoreflect APIs for their client language.
  710. optional FeatureSet features = 1;
  711. // The parser stores options it doesn't recognize here. See above.
  712. repeated UninterpretedOption uninterpreted_option = 999;
  713. // Clients can define custom options in extensions of this message. See above.
  714. extensions 1000 to max;
  715. }
  716. message EnumOptions {
  717. // Set this option to true to allow mapping different tag names to the same
  718. // value.
  719. optional bool allow_alias = 2;
  720. // Is this enum deprecated?
  721. // Depending on the target platform, this can emit Deprecated annotations
  722. // for the enum, or it will be completely ignored; in the very least, this
  723. // is a formalization for deprecating enums.
  724. optional bool deprecated = 3 [default = false];
  725. reserved 5; // javanano_as_lite
  726. // Enable the legacy handling of JSON field name conflicts. This lowercases
  727. // and strips underscored from the fields before comparison in proto3 only.
  728. // The new behavior takes `json_name` into account and applies to proto2 as
  729. // well.
  730. // TODO Remove this legacy behavior once downstream teams have
  731. // had time to migrate.
  732. optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
  733. // Any features defined in the specific edition.
  734. // WARNING: This field should only be used by protobuf plugins or special
  735. // cases like the proto compiler. Other uses are discouraged and
  736. // developers should rely on the protoreflect APIs for their client language.
  737. optional FeatureSet features = 7;
  738. // The parser stores options it doesn't recognize here. See above.
  739. repeated UninterpretedOption uninterpreted_option = 999;
  740. // Clients can define custom options in extensions of this message. See above.
  741. extensions 1000 to max;
  742. }
  743. message EnumValueOptions {
  744. // Is this enum value deprecated?
  745. // Depending on the target platform, this can emit Deprecated annotations
  746. // for the enum value, or it will be completely ignored; in the very least,
  747. // this is a formalization for deprecating enum values.
  748. optional bool deprecated = 1 [default = false];
  749. // Any features defined in the specific edition.
  750. // WARNING: This field should only be used by protobuf plugins or special
  751. // cases like the proto compiler. Other uses are discouraged and
  752. // developers should rely on the protoreflect APIs for their client language.
  753. optional FeatureSet features = 2;
  754. // Indicate that fields annotated with this enum value should not be printed
  755. // out when using debug formats, e.g. when the field contains sensitive
  756. // credentials.
  757. optional bool debug_redact = 3 [default = false];
  758. // Information about the support window of a feature value.
  759. optional FieldOptions.FeatureSupport feature_support = 4;
  760. // The parser stores options it doesn't recognize here. See above.
  761. repeated UninterpretedOption uninterpreted_option = 999;
  762. // Clients can define custom options in extensions of this message. See above.
  763. extensions 1000 to max;
  764. }
  765. message ServiceOptions {
  766. // Any features defined in the specific edition.
  767. // WARNING: This field should only be used by protobuf plugins or special
  768. // cases like the proto compiler. Other uses are discouraged and
  769. // developers should rely on the protoreflect APIs for their client language.
  770. optional FeatureSet features = 34;
  771. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  772. // framework. We apologize for hoarding these numbers to ourselves, but
  773. // we were already using them long before we decided to release Protocol
  774. // Buffers.
  775. // Is this service deprecated?
  776. // Depending on the target platform, this can emit Deprecated annotations
  777. // for the service, or it will be completely ignored; in the very least,
  778. // this is a formalization for deprecating services.
  779. optional bool deprecated = 33 [default = false];
  780. // The parser stores options it doesn't recognize here. See above.
  781. repeated UninterpretedOption uninterpreted_option = 999;
  782. // Clients can define custom options in extensions of this message. See above.
  783. extensions 1000 to max;
  784. }
  785. message MethodOptions {
  786. // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
  787. // framework. We apologize for hoarding these numbers to ourselves, but
  788. // we were already using them long before we decided to release Protocol
  789. // Buffers.
  790. // Is this method deprecated?
  791. // Depending on the target platform, this can emit Deprecated annotations
  792. // for the method, or it will be completely ignored; in the very least,
  793. // this is a formalization for deprecating methods.
  794. optional bool deprecated = 33 [default = false];
  795. // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
  796. // or neither? HTTP based RPC implementation may choose GET verb for safe
  797. // methods, and PUT verb for idempotent methods instead of the default POST.
  798. enum IdempotencyLevel {
  799. IDEMPOTENCY_UNKNOWN = 0;
  800. NO_SIDE_EFFECTS = 1; // implies idempotent
  801. IDEMPOTENT = 2; // idempotent, but may have side effects
  802. }
  803. optional IdempotencyLevel idempotency_level = 34
  804. [default = IDEMPOTENCY_UNKNOWN];
  805. // Any features defined in the specific edition.
  806. // WARNING: This field should only be used by protobuf plugins or special
  807. // cases like the proto compiler. Other uses are discouraged and
  808. // developers should rely on the protoreflect APIs for their client language.
  809. optional FeatureSet features = 35;
  810. // The parser stores options it doesn't recognize here. See above.
  811. repeated UninterpretedOption uninterpreted_option = 999;
  812. // Clients can define custom options in extensions of this message. See above.
  813. extensions 1000 to max;
  814. }
  815. // A message representing a option the parser does not recognize. This only
  816. // appears in options protos created by the compiler::Parser class.
  817. // DescriptorPool resolves these when building Descriptor objects. Therefore,
  818. // options protos in descriptor objects (e.g. returned by Descriptor::options(),
  819. // or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
  820. // in them.
  821. message UninterpretedOption {
  822. // The name of the uninterpreted option. Each string represents a segment in
  823. // a dot-separated name. is_extension is true iff a segment represents an
  824. // extension (denoted with parentheses in options specs in .proto files).
  825. // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
  826. // "foo.(bar.baz).moo".
  827. message NamePart {
  828. required string name_part = 1;
  829. required bool is_extension = 2;
  830. }
  831. repeated NamePart name = 2;
  832. // The value of the uninterpreted option, in whatever type the tokenizer
  833. // identified it as during parsing. Exactly one of these should be set.
  834. optional string identifier_value = 3;
  835. optional uint64 positive_int_value = 4;
  836. optional int64 negative_int_value = 5;
  837. optional double double_value = 6;
  838. optional bytes string_value = 7;
  839. optional string aggregate_value = 8;
  840. }
  841. // ===================================================================
  842. // Features
  843. // TODO Enums in C++ gencode (and potentially other languages) are
  844. // not well scoped. This means that each of the feature enums below can clash
  845. // with each other. The short names we've chosen maximize call-site
  846. // readability, but leave us very open to this scenario. A future feature will
  847. // be designed and implemented to handle this, hopefully before we ever hit a
  848. // conflict here.
  849. message FeatureSet {
  850. enum FieldPresence {
  851. FIELD_PRESENCE_UNKNOWN = 0;
  852. EXPLICIT = 1;
  853. IMPLICIT = 2;
  854. LEGACY_REQUIRED = 3;
  855. }
  856. optional FieldPresence field_presence = 1 [
  857. retention = RETENTION_RUNTIME,
  858. targets = TARGET_TYPE_FIELD,
  859. targets = TARGET_TYPE_FILE,
  860. feature_support = {
  861. edition_introduced: EDITION_2023,
  862. },
  863. edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" },
  864. edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" },
  865. edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" }
  866. ];
  867. enum EnumType {
  868. ENUM_TYPE_UNKNOWN = 0;
  869. OPEN = 1;
  870. CLOSED = 2;
  871. }
  872. optional EnumType enum_type = 2 [
  873. retention = RETENTION_RUNTIME,
  874. targets = TARGET_TYPE_ENUM,
  875. targets = TARGET_TYPE_FILE,
  876. feature_support = {
  877. edition_introduced: EDITION_2023,
  878. },
  879. edition_defaults = { edition: EDITION_LEGACY, value: "CLOSED" },
  880. edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" }
  881. ];
  882. enum RepeatedFieldEncoding {
  883. REPEATED_FIELD_ENCODING_UNKNOWN = 0;
  884. PACKED = 1;
  885. EXPANDED = 2;
  886. }
  887. optional RepeatedFieldEncoding repeated_field_encoding = 3 [
  888. retention = RETENTION_RUNTIME,
  889. targets = TARGET_TYPE_FIELD,
  890. targets = TARGET_TYPE_FILE,
  891. feature_support = {
  892. edition_introduced: EDITION_2023,
  893. },
  894. edition_defaults = { edition: EDITION_LEGACY, value: "EXPANDED" },
  895. edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" }
  896. ];
  897. enum Utf8Validation {
  898. UTF8_VALIDATION_UNKNOWN = 0;
  899. VERIFY = 2;
  900. NONE = 3;
  901. reserved 1;
  902. }
  903. optional Utf8Validation utf8_validation = 4 [
  904. retention = RETENTION_RUNTIME,
  905. targets = TARGET_TYPE_FIELD,
  906. targets = TARGET_TYPE_FILE,
  907. feature_support = {
  908. edition_introduced: EDITION_2023,
  909. },
  910. edition_defaults = { edition: EDITION_LEGACY, value: "NONE" },
  911. edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" }
  912. ];
  913. enum MessageEncoding {
  914. MESSAGE_ENCODING_UNKNOWN = 0;
  915. LENGTH_PREFIXED = 1;
  916. DELIMITED = 2;
  917. }
  918. optional MessageEncoding message_encoding = 5 [
  919. retention = RETENTION_RUNTIME,
  920. targets = TARGET_TYPE_FIELD,
  921. targets = TARGET_TYPE_FILE,
  922. feature_support = {
  923. edition_introduced: EDITION_2023,
  924. },
  925. edition_defaults = { edition: EDITION_LEGACY, value: "LENGTH_PREFIXED" }
  926. ];
  927. enum JsonFormat {
  928. JSON_FORMAT_UNKNOWN = 0;
  929. ALLOW = 1;
  930. LEGACY_BEST_EFFORT = 2;
  931. }
  932. optional JsonFormat json_format = 6 [
  933. retention = RETENTION_RUNTIME,
  934. targets = TARGET_TYPE_MESSAGE,
  935. targets = TARGET_TYPE_ENUM,
  936. targets = TARGET_TYPE_FILE,
  937. feature_support = {
  938. edition_introduced: EDITION_2023,
  939. },
  940. edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY_BEST_EFFORT" },
  941. edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" }
  942. ];
  943. enum EnforceNamingStyle {
  944. ENFORCE_NAMING_STYLE_UNKNOWN = 0;
  945. STYLE2024 = 1;
  946. STYLE_LEGACY = 2;
  947. }
  948. optional EnforceNamingStyle enforce_naming_style = 7 [
  949. retention = RETENTION_SOURCE,
  950. targets = TARGET_TYPE_FILE,
  951. targets = TARGET_TYPE_EXTENSION_RANGE,
  952. targets = TARGET_TYPE_MESSAGE,
  953. targets = TARGET_TYPE_FIELD,
  954. targets = TARGET_TYPE_ONEOF,
  955. targets = TARGET_TYPE_ENUM,
  956. targets = TARGET_TYPE_ENUM_ENTRY,
  957. targets = TARGET_TYPE_SERVICE,
  958. targets = TARGET_TYPE_METHOD,
  959. feature_support = {
  960. edition_introduced: EDITION_2024,
  961. },
  962. edition_defaults = { edition: EDITION_LEGACY, value: "STYLE_LEGACY" },
  963. edition_defaults = { edition: EDITION_2024, value: "STYLE2024" }
  964. ];
  965. message VisibilityFeature {
  966. enum DefaultSymbolVisibility {
  967. DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0;
  968. // Default pre-EDITION_2024, all UNSET visibility are export.
  969. EXPORT_ALL = 1;
  970. // All top-level symbols default to export, nested default to local.
  971. EXPORT_TOP_LEVEL = 2;
  972. // All symbols default to local.
  973. LOCAL_ALL = 3;
  974. // All symbols local by default. Nested types cannot be exported.
  975. // With special case caveat for message { enum {} reserved 1 to max; }
  976. // This is the recommended setting for new protos.
  977. STRICT = 4;
  978. }
  979. reserved 1 to max;
  980. }
  981. optional VisibilityFeature.DefaultSymbolVisibility default_symbol_visibility =
  982. 8 [
  983. retention = RETENTION_SOURCE,
  984. targets = TARGET_TYPE_FILE,
  985. feature_support = {
  986. edition_introduced: EDITION_2024,
  987. },
  988. edition_defaults = { edition: EDITION_LEGACY, value: "EXPORT_ALL" },
  989. edition_defaults = { edition: EDITION_2024, value: "EXPORT_TOP_LEVEL" }
  990. ];
  991. reserved 999;
  992. extensions 1000 to 9994 [
  993. declaration = {
  994. number: 1000,
  995. full_name: ".pb.cpp",
  996. type: ".pb.CppFeatures"
  997. },
  998. declaration = {
  999. number: 1001,
  1000. full_name: ".pb.java",
  1001. type: ".pb.JavaFeatures"
  1002. },
  1003. declaration = { number: 1002, full_name: ".pb.go", type: ".pb.GoFeatures" },
  1004. declaration = {
  1005. number: 1003,
  1006. full_name: ".pb.python",
  1007. type: ".pb.PythonFeatures"
  1008. },
  1009. declaration = {
  1010. number: 9990,
  1011. full_name: ".pb.proto1",
  1012. type: ".pb.Proto1Features"
  1013. }
  1014. ];
  1015. extensions 9995 to 9999; // For internal testing
  1016. extensions 10000; // for https://github.com/bufbuild/protobuf-es
  1017. }
  1018. // A compiled specification for the defaults of a set of features. These
  1019. // messages are generated from FeatureSet extensions and can be used to seed
  1020. // feature resolution. The resolution with this object becomes a simple search
  1021. // for the closest matching edition, followed by proto merges.
  1022. message FeatureSetDefaults {
  1023. // A map from every known edition with a unique set of defaults to its
  1024. // defaults. Not all editions may be contained here. For a given edition,
  1025. // the defaults at the closest matching edition ordered at or before it should
  1026. // be used. This field must be in strict ascending order by edition.
  1027. message FeatureSetEditionDefault {
  1028. optional Edition edition = 3;
  1029. // Defaults of features that can be overridden in this edition.
  1030. optional FeatureSet overridable_features = 4;
  1031. // Defaults of features that can't be overridden in this edition.
  1032. optional FeatureSet fixed_features = 5;
  1033. reserved 1, 2;
  1034. reserved "features";
  1035. }
  1036. repeated FeatureSetEditionDefault defaults = 1;
  1037. // The minimum supported edition (inclusive) when this was constructed.
  1038. // Editions before this will not have defaults.
  1039. optional Edition minimum_edition = 4;
  1040. // The maximum known edition (inclusive) when this was constructed. Editions
  1041. // after this will not have reliable defaults.
  1042. optional Edition maximum_edition = 5;
  1043. }
  1044. // ===================================================================
  1045. // Optional source code info
  1046. // Encapsulates information about the original source file from which a
  1047. // FileDescriptorProto was generated.
  1048. message SourceCodeInfo {
  1049. // A Location identifies a piece of source code in a .proto file which
  1050. // corresponds to a particular definition. This information is intended
  1051. // to be useful to IDEs, code indexers, documentation generators, and similar
  1052. // tools.
  1053. //
  1054. // For example, say we have a file like:
  1055. // message Foo {
  1056. // optional string foo = 1;
  1057. // }
  1058. // Let's look at just the field definition:
  1059. // optional string foo = 1;
  1060. // ^ ^^ ^^ ^ ^^^
  1061. // a bc de f ghi
  1062. // We have the following locations:
  1063. // span path represents
  1064. // [a,i) [ 4, 0, 2, 0 ] The whole field definition.
  1065. // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
  1066. // [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
  1067. // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
  1068. // [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
  1069. //
  1070. // Notes:
  1071. // - A location may refer to a repeated field itself (i.e. not to any
  1072. // particular index within it). This is used whenever a set of elements are
  1073. // logically enclosed in a single code segment. For example, an entire
  1074. // extend block (possibly containing multiple extension definitions) will
  1075. // have an outer location whose path refers to the "extensions" repeated
  1076. // field without an index.
  1077. // - Multiple locations may have the same path. This happens when a single
  1078. // logical declaration is spread out across multiple places. The most
  1079. // obvious example is the "extend" block again -- there may be multiple
  1080. // extend blocks in the same scope, each of which will have the same path.
  1081. // - A location's span is not always a subset of its parent's span. For
  1082. // example, the "extendee" of an extension declaration appears at the
  1083. // beginning of the "extend" block and is shared by all extensions within
  1084. // the block.
  1085. // - Just because a location's span is a subset of some other location's span
  1086. // does not mean that it is a descendant. For example, a "group" defines
  1087. // both a type and a field in a single declaration. Thus, the locations
  1088. // corresponding to the type and field and their components will overlap.
  1089. // - Code which tries to interpret locations should probably be designed to
  1090. // ignore those that it doesn't understand, as more types of locations could
  1091. // be recorded in the future.
  1092. repeated Location location = 1;
  1093. message Location {
  1094. // Identifies which part of the FileDescriptorProto was defined at this
  1095. // location.
  1096. //
  1097. // Each element is a field number or an index. They form a path from
  1098. // the root FileDescriptorProto to the place where the definition appears.
  1099. // For example, this path:
  1100. // [ 4, 3, 2, 7, 1 ]
  1101. // refers to:
  1102. // file.message_type(3) // 4, 3
  1103. // .field(7) // 2, 7
  1104. // .name() // 1
  1105. // This is because FileDescriptorProto.message_type has field number 4:
  1106. // repeated DescriptorProto message_type = 4;
  1107. // and DescriptorProto.field has field number 2:
  1108. // repeated FieldDescriptorProto field = 2;
  1109. // and FieldDescriptorProto.name has field number 1:
  1110. // optional string name = 1;
  1111. //
  1112. // Thus, the above path gives the location of a field name. If we removed
  1113. // the last element:
  1114. // [ 4, 3, 2, 7 ]
  1115. // this path refers to the whole field declaration (from the beginning
  1116. // of the label to the terminating semicolon).
  1117. repeated int32 path = 1 [packed = true];
  1118. // Always has exactly three or four elements: start line, start column,
  1119. // end line (optional, otherwise assumed same as start line), end column.
  1120. // These are packed into a single field for efficiency. Note that line
  1121. // and column numbers are zero-based -- typically you will want to add
  1122. // 1 to each before displaying to a user.
  1123. repeated int32 span = 2 [packed = true];
  1124. // If this SourceCodeInfo represents a complete declaration, these are any
  1125. // comments appearing before and after the declaration which appear to be
  1126. // attached to the declaration.
  1127. //
  1128. // A series of line comments appearing on consecutive lines, with no other
  1129. // tokens appearing on those lines, will be treated as a single comment.
  1130. //
  1131. // leading_detached_comments will keep paragraphs of comments that appear
  1132. // before (but not connected to) the current element. Each paragraph,
  1133. // separated by empty lines, will be one comment element in the repeated
  1134. // field.
  1135. //
  1136. // Only the comment content is provided; comment markers (e.g. //) are
  1137. // stripped out. For block comments, leading whitespace and an asterisk
  1138. // will be stripped from the beginning of each line other than the first.
  1139. // Newlines are included in the output.
  1140. //
  1141. // Examples:
  1142. //
  1143. // optional int32 foo = 1; // Comment attached to foo.
  1144. // // Comment attached to bar.
  1145. // optional int32 bar = 2;
  1146. //
  1147. // optional string baz = 3;
  1148. // // Comment attached to baz.
  1149. // // Another line attached to baz.
  1150. //
  1151. // // Comment attached to moo.
  1152. // //
  1153. // // Another line attached to moo.
  1154. // optional double moo = 4;
  1155. //
  1156. // // Detached comment for corge. This is not leading or trailing comments
  1157. // // to moo or corge because there are blank lines separating it from
  1158. // // both.
  1159. //
  1160. // // Detached comment for corge paragraph 2.
  1161. //
  1162. // optional string corge = 5;
  1163. // /* Block comment attached
  1164. // * to corge. Leading asterisks
  1165. // * will be removed. */
  1166. // /* Block comment attached to
  1167. // * grault. */
  1168. // optional int32 grault = 6;
  1169. //
  1170. // // ignored detached comments.
  1171. optional string leading_comments = 3;
  1172. optional string trailing_comments = 4;
  1173. repeated string leading_detached_comments = 6;
  1174. }
  1175. // Extensions for tooling.
  1176. extensions 536000000 [declaration = {
  1177. number: 536000000
  1178. type: ".buf.descriptor.v1.SourceCodeInfoExtension"
  1179. full_name: ".buf.descriptor.v1.buf_source_code_info_extension"
  1180. }];
  1181. }
  1182. // Describes the relationship between generated code and its original source
  1183. // file. A GeneratedCodeInfo message is associated with only one generated
  1184. // source file, but may contain references to different source .proto files.
  1185. message GeneratedCodeInfo {
  1186. // An Annotation connects some span of text in generated code to an element
  1187. // of its generating .proto file.
  1188. repeated Annotation annotation = 1;
  1189. message Annotation {
  1190. // Identifies the element in the original source .proto file. This field
  1191. // is formatted the same as SourceCodeInfo.Location.path.
  1192. repeated int32 path = 1 [packed = true];
  1193. // Identifies the filesystem path to the original source .proto.
  1194. optional string source_file = 2;
  1195. // Identifies the starting offset in bytes in the generated code
  1196. // that relates to the identified object.
  1197. optional int32 begin = 3;
  1198. // Identifies the ending offset in bytes in the generated code that
  1199. // relates to the identified object. The end offset should be one past
  1200. // the last relevant byte (so the length of the text = end - begin).
  1201. optional int32 end = 4;
  1202. // Represents the identified object's effect on the element in the original
  1203. // .proto file.
  1204. enum Semantic {
  1205. // There is no effect or the effect is indescribable.
  1206. NONE = 0;
  1207. // The element is set or otherwise mutated.
  1208. SET = 1;
  1209. // An alias to the element is returned.
  1210. ALIAS = 2;
  1211. }
  1212. optional Semantic semantic = 5;
  1213. }
  1214. }
  1215. // Describes the 'visibility' of a symbol with respect to the proto import
  1216. // system. Symbols can only be imported when the visibility rules do not prevent
  1217. // it (ex: local symbols cannot be imported). Visibility modifiers can only set
  1218. // on `message` and `enum` as they are the only types available to be referenced
  1219. // from other files.
  1220. enum SymbolVisibility {
  1221. VISIBILITY_UNSET = 0;
  1222. VISIBILITY_LOCAL = 1;
  1223. VISIBILITY_EXPORT = 2;
  1224. }