Description
OpenAPI 2.0 permits allowEmptyValue on query and formData parameters. OpenAPI 3.0 limits it to query and discourages its use. required controls whether the parameter must be present.
Potential impact
Clients may send empty values at locations where tools ignore or reject the setting.
Remediation
Check the version and parameter location. For a path parameter, remove allowEmptyValue and keep the route. For a query parameter, test omission and an empty value separately.
Examples
These OpenAPI 3.0 excerpts omit info and the operation’s responses.
Before
{
"openapi": "3.0.0",
"paths": {
"/users/{id}": {
"get": {
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"allowEmptyValue": true,
"schema": {
"type": "integer"
}
}
]
}
}
}
}
After
{
"openapi": "3.0.0",
"paths": {
"/users": {
"get": {
"parameters": [
{
"name": "id",
"in": "query",
"allowEmptyValue": true,
"schema": {
"type": "integer"
}
}
]
}
}
}
}
Changing /users/{id} to /users moves id into the query. Omitting required also makes it optional. Use this version only if clients may call the new route without an ID.