Description
Required fields in OpenAPI 2.0 depend on the object. info needs title and version. A body parameter needs schema, and other parameters need type.
Potential impact
A missing field can stop a validator or client generator from reading the definition.
Remediation
Check each reported object against its definition, including any requirements for the chosen security scheme. Supply the API’s actual values and validate the document.
Examples
The example omits info.version and the query parameter’s type.
Before
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true
}
}
}
After
json
{
"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": {
"limitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"type": "string"
}
}
}
Use the type that limit actually accepts.