Unused parameter component (OpenAPI 3.0)

A reusable parameter is not applied to a path or operation

Description

components.parameters stores shared parameters. To document one for a request, reference it from the path or operation’s parameters.

Potential impact

Readers may be unable to tell which operations accept the parameter.

Remediation

Use $ref wherever the parameter applies. Check its name, location and whether the API requires it. Before deleting an unused definition, check for references from other documents.

Examples

The first example defines limitParam. The revised GET operation references it to document limit as a required query parameter.

Before

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "limitParam": {
        "name": "limit",
        "in": "query",
        "description": "max records to return",
        "required": true,
        "schema": {
          "type": "integer"
        }
      }
    }
  }
}

After

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "Success"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/limitParam"
          }
        ]
      }
    }
  },
  "components": {
    "parameters": {
      "limitParam": {
        "name": "limit",
        "in": "query",
        "description": "max records to return",
        "required": true,
        "schema": {
          "type": "integer"
        }
      }
    }
  }
}

References