Components Parameter Definition Is Unused
- Query id: 698a464e-bb3e-4ba8-ab5e-e6599b7644a0
- Query name: Components Parameter Definition Is Unused
- Platform: OpenAPI
- Severity: Info
- Category: Best Practices
- URL: Github
Description¶
Components parameters definitions should be referenced or removed from Open API definition
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"$ref": "#/components/schemas/Success"
}
}
}
}
},
"components": {
"parameters": {
"limitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
}
Positive test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
"$ref": "#/components/schemas/Success"
components:
parameters:
limitParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"$ref": "#/components/schemas/Success"
}
},
"parameters": [
{
"$ref": "#/components/parameters/limitParam"
}
]
}
}
},
"components": {
"parameters": {
"limitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
}
Negative test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
"$ref": "#/components/schemas/Success"
parameters:
- "$ref": "#/components/parameters/limitParam"
components:
parameters:
limitParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer