Description
An OpenAPI 2.0 operation accepts at most one in: body parameter.
Potential impact
Multiple body parameters can break validation or leave clients unsure what to send.
Remediation
If the server expects several body fields, put them in one object schema. Move a value to a query parameter or header only if the server accepts it there. Use formData separately from body.
Examples
The revised POST keeps limit in the body and takes pageCount as an integer query parameter.
Before
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"post": {
"parameters": [
{
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "string"
}
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}
After
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"post": {
"parameters": [
{
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "pageCount",
"in": "query",
"description": "records per page",
"required": true,
"type": "integer"
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}