{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/RateLimitRule",
  "title": "RateLimitRule",
  "type": "object",
  "description": "A single rate limiting rule with a pattern and rate",
  "required": [
    "pattern",
    "rate"
  ],
  "properties": {
    "pattern": {
      "type": "array",
      "description": "Descriptor entries to match against. Each entry is a key-value pair that must match the labels sent with the request.",
      "items": {
        "type": "object",
        "additionalProperties": {
          "type": "string"
        }
      },
      "example": [
        {
          "generic_key": "my-rate-limit"
        }
      ]
    },
    "rate": {
      "type": "integer",
      "description": "Maximum number of requests allowed in the specified unit of time",
      "minimum": 1,
      "example": 10
    },
    "unit": {
      "type": "string",
      "description": "Time unit for the rate limit",
      "enum": [
        "second",
        "minute",
        "hour",
        "day"
      ],
      "default": "minute",
      "example": "second"
    },
    "injectRequestHeaders": {
      "type": "array",
      "description": "Headers to inject into the request when the rate limit is applied",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      },
      "example": []
    }
  }
}