Global Parameter Definition Not Being Used

  • Query id: b30981fa-a12e-49c7-a5bb-eeafb61d0f0f
  • Query name: Global Parameter Definition Not Being Used
  • Platform: OpenAPI
  • Severity: Info
  • Category: Best Practices
  • URL: Github

Description

All global parameters definitions should be in use
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": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        },
        "parameters": [
          {
            "$ref": "#/parameters/limitParame"
          }
        ]
      }
    }
  },
  "parameters": {
    "limitParam": {
      "name": "limit",
      "in": "body",
      "description": "max records to return",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  }
}
Positive test num. 2 - yaml file
swagger: "2.0"
info:
  title: Simple API Overview
  version: 1.0.0
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: 200 response
      parameters:
        - "$ref": "#/parameters/limitParame"
parameters:
  limitParam:
    name: limit
    in: body
    description: max records to return
    required: true
    schema:
      type: string

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