Invalid location for collectionFormat: multi (OpenAPI 2.0)

An array uses multi outside query or formData

Description

collectionFormat: multi repeats a parameter name for each array item. OpenAPI 2.0 supports it for query and formData only.

Potential impact

If the client and server encode an array differently, the request can fail.

Remediation

For a path or header array, use a supported format the server reads, such as csv. Move the array to the query only if the endpoint accepts it there.

Examples

The revision moves limit2 to the query, keeps multi, and changes the route from /{limit2} to /. The separate limitParam path definition uses csv.

Before

json
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/{limit2}": {
      "get": {
        "parameters": [
          {
            "name": "limit2",
            "in": "path",
            "description": "max records to return",
            "required": true,
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "collectionFormat": "multi"
          }
        ],
        "operationId": "listVersionsV2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  },
  "parameters": {
    "limitParam": {
      "name": "limit",
      "in": "path",
      "description": "max records to return",
      "required": true,
      "type": "array",
      "items": {
        "type": "integer",
        "format": "int64"
      },
      "collectionFormat": "multi"
    }
  }
}

After

json
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "parameters": [
          {
            "name": "limit2",
            "in": "query",
            "description": "max records to return",
            "required": true,
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "collectionFormat": "multi"
          }
        ],
        "operationId": "listVersionsV2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  },
  "parameters": {
    "limitParam": {
      "name": "limit",
      "in": "path",
      "description": "max records to return",
      "required": true,
      "type": "array",
      "items": {
        "type": "integer",
        "format": "int64"
      },
      "collectionFormat": "csv"
    }
  }
}

References