Description
In OpenAPI 2.0, query, path, header, and formData parameters declare type directly on the parameter.
Potential impact
A nested schema can cause validation to fail or leave a generated client without the right type.
Remediation
Move the type out of schema and keep any applicable format. For an array, declare type: array and put items alongside it.
Examples
The revision sets type: integer on limit2 and the reusable path parameter limitParam. The operation uses only limit2.
Before
json
{
"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,
"schema": {
"type": "integer"
}
}
],
"operationId": "listVersionsV2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "path",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
After
json
{
"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": "integer"
}
],
"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": "integer"
}
}
}