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