go_features.proto 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2023 Google Inc. All rights reserved.
  3. //
  4. // Use of this source code is governed by a BSD-style
  5. // license that can be found in the LICENSE file or at
  6. // https://developers.google.com/open-source/licenses/bsd
  7. syntax = "proto2";
  8. package pb;
  9. import "google/protobuf/descriptor.proto";
  10. option go_package = "google.golang.org/protobuf/types/gofeaturespb";
  11. extend google.protobuf.FeatureSet {
  12. optional GoFeatures go = 1002;
  13. }
  14. message GoFeatures {
  15. // Whether or not to generate the deprecated UnmarshalJSON method for enums.
  16. // Can only be true for proto using the Open Struct api.
  17. optional bool legacy_unmarshal_json_enum = 1 [
  18. retention = RETENTION_RUNTIME,
  19. targets = TARGET_TYPE_ENUM,
  20. targets = TARGET_TYPE_FILE,
  21. feature_support = {
  22. edition_introduced: EDITION_2023,
  23. edition_deprecated: EDITION_2023,
  24. deprecation_warning: "The legacy UnmarshalJSON API is deprecated and "
  25. "will be removed in a future edition.",
  26. },
  27. edition_defaults = { edition: EDITION_LEGACY, value: "true" },
  28. edition_defaults = { edition: EDITION_PROTO3, value: "false" }
  29. ];
  30. enum APILevel {
  31. // API_LEVEL_UNSPECIFIED results in selecting the OPEN API,
  32. // but needs to be a separate value to distinguish between
  33. // an explicitly set api level or a missing api level.
  34. API_LEVEL_UNSPECIFIED = 0;
  35. API_OPEN = 1;
  36. API_HYBRID = 2;
  37. API_OPAQUE = 3;
  38. }
  39. // One of OPEN, HYBRID or OPAQUE.
  40. optional APILevel api_level = 2 [
  41. retention = RETENTION_RUNTIME,
  42. targets = TARGET_TYPE_MESSAGE,
  43. targets = TARGET_TYPE_FILE,
  44. feature_support = {
  45. edition_introduced: EDITION_2023,
  46. },
  47. edition_defaults = { edition: EDITION_LEGACY, value: "API_LEVEL_UNSPECIFIED" },
  48. edition_defaults = { edition: EDITION_2024, value: "API_OPAQUE" }
  49. ];
  50. enum StripEnumPrefix {
  51. STRIP_ENUM_PREFIX_UNSPECIFIED = 0;
  52. STRIP_ENUM_PREFIX_KEEP = 1;
  53. STRIP_ENUM_PREFIX_GENERATE_BOTH = 2;
  54. STRIP_ENUM_PREFIX_STRIP = 3;
  55. }
  56. optional StripEnumPrefix strip_enum_prefix = 3 [
  57. retention = RETENTION_RUNTIME,
  58. targets = TARGET_TYPE_ENUM,
  59. targets = TARGET_TYPE_ENUM_ENTRY,
  60. targets = TARGET_TYPE_FILE,
  61. feature_support = {
  62. edition_introduced: EDITION_2024,
  63. },
  64. // TODO: change the default to STRIP_ENUM_PREFIX_STRIP for edition 2025.
  65. edition_defaults = {
  66. edition: EDITION_LEGACY,
  67. value: "STRIP_ENUM_PREFIX_KEEP"
  68. }
  69. ];
  70. }