Multiple Body Parameters In The Same Operation

  • Query id: b90033cf-ad9f-4fb9-acd1-1b9d6d278c87
  • Query name: Multiple Body Parameters In The Same Operation
  • Platform: OpenAPI
  • Severity: Info
  • Category: Structure and Semantics
  • URL: Github

Description

Only one body parameter is allowed on operation's parameters type field
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": "limit",
            "in": "body",
            "description": "max records to return",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit2",
            "in": "body",
            "description": "max records to return",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  }
}
Positive test num. 2 - yaml file
swagger: '2.0'
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      parameters:
      - name: limit
        in: body
        description: max records to return
        required: true
        schema:
          type: integer
      - name: limit2
        in: body
        description: max records to return
        required: true
        schema:
          type: string
      operationId: listVersionsv2
      summary: List API versions
      responses:
        '200':
          description: 200 response

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": "limit",
            "in": "body",
            "description": "max records to return",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "pageCount",
            "in": "query",
            "description": "records per page",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  }
}
Negative test num. 2 - yaml file
swagger: '2.0'
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      parameters:
      - name: limit
        in: body
        description: max records to return
        required: true
        schema:
          type: integer
      - name: pageCount
        in: query
        description: records per page
        required: true
        schema:
          type: integer
      operationId: listVersionsv2
      summary: List API versions
      responses:
        '200':
          description: 200 response