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