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