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