Description
In OpenAPI 2.0 and 3.0, a path placeholder always needs a value.
Potential impact
Tools may reject an optional path parameter or generate a client that omits a required URL segment.
Remediation
Set required: true on every in: path parameter. Match its name to the placeholder and its type and format to what the server accepts.
Examples
These OpenAPI 3.0 excerpts omit info and the operation’s responses.
Before
json
{
"openapi": "3.0.0",
"paths": {
"/users/{id}": {
"get": {
"parameters": [
{
"name": "id",
"in": "path",
"required": false,
"schema": {
"type": "integer"
}
}
]
}
}
}
}
After
json
{
"openapi": "3.0.0",
"paths": {
"/users/{id}": {
"get": {
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
}
]
}
}
}
}
In /users/{id}, the revised definition makes the integer id mandatory.