{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/buf.policy.json",
  "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml",
  "$defs": {
    "lint-rule": {
      "type": "string",
      "description": "https://buf.build/docs/lint/rules",
      "examples": [
        "STANDARD",
        "DEFAULT",
        "BASIC",
        "MINIMAL",
        "COMMENTS",
        "UNARY_RPC",
        "DIRECTORY_SAME_PACKAGE",
        "PACKAGE_DEFINED",
        "PACKAGE_DIRECTORY_MATCH",
        "PACKAGE_SAME_DIRECTORY",
        "ENUM_PASCAL_CASE",
        "ENUM_VALUE_UPPER_SNAKE_CASE",
        "FIELD_LOWER_SNAKE_CASE",
        "MESSAGE_PASCAL_CASE",
        "ONEOF_LOWER_SNAKE_CASE",
        "PACKAGE_LOWER_SNAKE_CASE",
        "RPC_PASCAL_CASE",
        "SERVICE_PASCAL_CASE",
        "PACKAGE_SAME_CSHARP_NAMESPACE",
        "PACKAGE_SAME_GO_PACKAGE",
        "PACKAGE_SAME_JAVA_MULTIPLE_FILES",
        "PACKAGE_SAME_JAVA_PACKAGE",
        "PACKAGE_SAME_PHP_NAMESPACE",
        "PACKAGE_SAME_RUBY_PACKAGE",
        "PACKAGE_SAME_SWIFT_PREFIX",
        "ENUM_FIRST_VALUE_ZERO",
        "ENUM_NO_ALLOW_ALIAS",
        "IMPORT_NO_WEAK",
        "IMPORT_NO_PUBLIC",
        "IMPORT_USED",
        "ENUM_VALUE_PREFIX",
        "ENUM_ZERO_VALUE_SUFFIX",
        "FIELD_NOT_REQUIRED",
        "FILE_LOWER_SNAKE_CASE",
        "RPC_REQUEST_RESPONSE_UNIQUE",
        "RPC_REQUEST_STANDARD_NAME",
        "RPC_RESPONSE_STANDARD_NAME",
        "PACKAGE_VERSION_SUFFIX",
        "PROTOVALIDATE",
        "SERVICE_SUFFIX",
        "COMMENT_ENUM",
        "COMMENT_ENUM_VALUE",
        "COMMENT_FIELD",
        "COMMENT_MESSAGE",
        "COMMENT_ONEOF",
        "COMMENT_RPC",
        "COMMENT_SERVICE",
        "RPC_NO_CLIENT_STREAMING",
        "RPC_NO_SERVER_STREAMING",
        "PACKAGE_NO_IMPORT_CYCLE",
        "SYNTAX_SPECIFIED",
        "STABLE_PACKAGE_NO_IMPORT_UNSTABLE"
      ]
    },
    "breaking-rule": {
      "type": "string",
      "description": "https://buf.build/docs/breaking/rules",
      "examples": [
        "FILE",
        "PACKAGE",
        "WIRE_JSON",
        "WIRE",
        "ENUM_NO_DELETE",
        "ENUM_SAME_JSON_FORMAT",
        "ENUM_SAME_TYPE",
        "ENUM_VALUE_NO_DELETE",
        "ENUM_VALUE_NO_DELETE_UNLESS_NAME_RESERVED",
        "ENUM_VALUE_NO_DELETE_UNLESS_NUMBER_RESERVED",
        "ENUM_VALUE_SAME_NAME",
        "EXTENSION_MESSAGE_NO_DELETE",
        "EXTENSION_NO_DELETE",
        "FIELD_NO_DELETE",
        "FIELD_NO_DELETE_UNLESS_NAME_RESERVED",
        "FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED",
        "FIELD_SAME_CARDINALITY",
        "FIELD_SAME_CPP_STRING_TYPE",
        "FIELD_SAME_CTYPE",
        "FIELD_SAME_DEFAULT",
        "FIELD_SAME_JAVA_UTF8_VALIDATION",
        "FIELD_SAME_JSON_NAME",
        "FIELD_SAME_JSTYPE",
        "FIELD_SAME_LABEL",
        "FIELD_SAME_NAME",
        "FIELD_SAME_ONEOF",
        "FIELD_SAME_TYPE",
        "FIELD_SAME_UTF8_VALIDATION",
        "FIELD_WIRE_COMPATIBLE_CARDINALITY",
        "FIELD_WIRE_COMPATIBLE_TYPE",
        "FIELD_WIRE_JSON_COMPATIBLE_CARDINALITY",
        "FIELD_WIRE_JSON_COMPATIBLE_TYPE",
        "FILE_NO_DELETE",
        "FILE_SAME_CC_ENABLE_ARENAS",
        "FILE_SAME_CC_GENERIC_SERVICES",
        "FILE_SAME_CSHARP_NAMESPACE",
        "FILE_SAME_GO_PACKAGE",
        "FILE_SAME_JAVA_GENERIC_SERVICES",
        "FILE_SAME_JAVA_MULTIPLE_FILES",
        "FILE_SAME_JAVA_OUTER_CLASSNAME",
        "FILE_SAME_JAVA_PACKAGE",
        "FILE_SAME_JAVA_STRING_CHECK_UTF8",
        "FILE_SAME_OBJC_CLASS_PREFIX",
        "FILE_SAME_OPTIMIZE_FOR",
        "FILE_SAME_PACKAGE",
        "FILE_SAME_PHP_CLASS_PREFIX",
        "FILE_SAME_PHP_GENERIC_SERVICES",
        "FILE_SAME_PHP_METADATA_NAMESPACE",
        "FILE_SAME_PHP_NAMESPACE",
        "FILE_SAME_PY_GENERIC_SERVICES",
        "FILE_SAME_RUBY_PACKAGE",
        "FILE_SAME_SWIFT_PREFIX",
        "FILE_SAME_SYNTAX",
        "MESSAGE_NO_DELETE",
        "MESSAGE_NO_REMOVE_STANDARD_DESCRIPTOR_ACCESSOR",
        "MESSAGE_SAME_JSON_FORMAT",
        "MESSAGE_SAME_MESSAGE_SET_WIRE_FORMAT",
        "MESSAGE_SAME_REQUIRED_FIELDS",
        "ONEOF_NO_DELETE",
        "PACKAGE_ENUM_NO_DELETE",
        "PACKAGE_EXTENSION_NO_DELETE",
        "PACKAGE_MESSAGE_NO_DELETE",
        "PACKAGE_NO_DELETE",
        "PACKAGE_SERVICE_NO_DELETE",
        "RESERVED_ENUM_NO_DELETE",
        "RESERVED_MESSAGE_NO_DELETE",
        "RPC_NO_DELETE",
        "RPC_SAME_CLIENT_STREAMING",
        "RPC_SAME_IDEMPOTENCY_LEVEL",
        "RPC_SAME_REQUEST_TYPE",
        "RPC_SAME_RESPONSE_TYPE",
        "RPC_SAME_SERVER_STREAMING",
        "SERVICE_NO_DELETE"
      ]
    }
  },
  "title": "buf.policy.yaml",
  "description": "buf.policy.yaml defines a policy containing a subset of Buf configuration focused on lint, breaking change detection, and plugins. Policies can be shared across modules in the Buf Schema Registry.",
  "type": "object",
  "required": ["version"],
  "additionalProperties": false,
  "properties": {
    "version": {
      "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#version",
      "description": "Required. The version key defines the current configuration version. The only accepted value is v2.",
      "type": "string",
      "const": "v2"
    },
    "name": {
      "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#name",
      "description": "Optional. A BSR path that uniquely identifies this policy. Must be a valid policy name in the format buf.build/ORGANIZATION/POLICY_NAME.",
      "type": "string"
    },
    "lint": {
      "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#lint",
      "description": "Optional. The lint settings for this policy.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "use": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#use",
          "description": "Optional. Lists the categories and/or specific rules to use. The STANDARD category is used if lint is unset.",
          "type": "array",
          "default": ["STANDARD"],
          "items": {
            "$ref": "#/$defs/lint-rule"
          }
        },
        "except": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#except",
          "description": "Optional. Removes rules or categories from the use list.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/lint-rule"
          }
        },
        "enum_zero_value_suffix": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#enum_zero_value_suffix",
          "description": "Optional. Controls the behavior of the ENUM_ZERO_VALUE_SUFFIX lint rule. By default, this rule verifies that the zero value of all enums ends in _UNSPECIFIED.",
          "type": "string",
          "default": "_UNSPECIFIED"
        },
        "rpc_allow_same_request_response": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#rpc_allow_same_request_response",
          "description": "Optional. Allows the same message type to be used for a single RPC's request and response type. We don't recommend using this option.",
          "type": "boolean"
        },
        "rpc_allow_google_protobuf_empty_requests": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#rpc_allow_google_protobuf_empty_requests",
          "description": "Optional. Allows RPC requests to be google.protobuf.Empty messages. We don't recommend using this option.",
          "type": "boolean"
        },
        "rpc_allow_google_protobuf_empty_responses": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#rpc_allow_google_protobuf_empty_responses",
          "description": "Optional. Allows RPC responses to be google.protobuf.Empty messages. We don't recommend using this option.",
          "type": "boolean"
        },
        "service_suffix": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#service_suffix",
          "description": "Optional. Controls the behavior of the SERVICE_SUFFIX lint rule. By default, this rule verifies that all service names are suffixed with Service.",
          "type": "string",
          "default": "Service"
        },
        "disable_builtin": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#disable_builtin",
          "description": "Optional. Disables Buf's built-in lint rules when set to true. Defaults to false.",
          "type": "boolean",
          "default": false
        }
      }
    },
    "breaking": {
      "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#breaking",
      "description": "Optional. The breaking change detection settings for this policy.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "use": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#use-1",
          "description": "Optional. Lists the rules or categories to use for breaking change detection. The FILE category is used if breaking is unset.",
          "type": "array",
          "default": ["FILE"],
          "items": {
            "$ref": "#/$defs/breaking-rule"
          }
        },
        "except": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#except-1",
          "description": "Optional. Removes rules or categories from the use list. We don't recommend using this option.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/breaking-rule"
          }
        },
        "ignore_unstable_packages": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#ignore_unstable_packages",
          "description": "Optional. Ignores packages with a last component that's one of the unstable forms recognized by the Buf linter's PACKAGE_VERSION_SUFFIX rule.",
          "type": "boolean"
        },
        "disable_builtin": {
          "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#disable_builtin-1",
          "description": "Optional. Disables Buf's built-in breaking change detection rules when set to true. Defaults to false.",
          "type": "boolean",
          "default": false
        }
      }
    },
    "plugins": {
      "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#plugins",
      "description": "Optional. Custom Buf plugins that provide additional lint or breaking change rules.",
      "type": "array",
      "items": {
        "type": "object",
        "required": ["plugin"],
        "additionalProperties": false,
        "properties": {
          "plugin": {
            "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#plugin",
            "description": "Required. References a Buf plugin via local binary path, filesystem location, or remote BSR plugin path.",
            "type": "string"
          },
          "options": {
            "$comment": "https://buf.build/docs/configuration/v2/buf-policy-yaml#options",
            "description": "Optional. Key-value configuration pairs for plugin customization.",
            "type": "object"
          }
        }
      }
    }
  }
}
