Default value unnecessarily declared for a required parameter type
Issue ID: warning-parameter-required-default
Description
You have specified a default value for a required parameter. The values for required parameters are always specified in requests, so there is no need to specify a default value that the server could use.
For more details, see the OpenAPI Specification.
Example
The following is an example of how this issue could look in your API definition:
{
"post": {
"description": "Creates a new pet in the store",
"operationId": "addPet",
"parameters": [
{
"name": "pet",
"in": "body",
"description": "pet to add to the system",
"required": true,
"schema": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"default": "Fido"
}
// ...
}
}
}
]
}
}
Remediation
Make sure that you do not specify default responses for required parameters.
{
"post": {
"description": "Creates a new pet in the store",
"operationId": "addPet",
"parameters": [
{
"name": "pet",
"in": "body",
"description": "pet to add to the system",
"required": true,
"schema": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
}
// ...
}
}
}
]
}
}