Default value unnecessarily declared for the required parameter type

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 v2 or v3.

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"
           },
          ...
          }
         }
       }
     }
   ]
}

Get API Security news directly in your Inbox.

By clicking Subscribe you agree to our Data Policy