Multi 'collectionformat' Not Valid For 'in' Parameter

  • Query id: 750f6448-27c0-49f8-a153-b81735c1e19c
  • Query name: Multi 'collectionformat' Not Valid For 'in' Parameter
  • Platform: OpenAPI
  • Severity: Info
  • Category: Structure and Semantics
  • URL: Github

Description

When 'collectionformat' is defined as 'multi', 'in' field must be 'query' or 'formData'
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - json file
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "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"
    }
  }
}
Positive test num. 2 - yaml file
swagger: '2.0'
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    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

Code samples without security vulnerabilities

Negative test num. 1 - json file
{
  "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"
    }
  }
}
Negative test num. 2 - yaml file
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