Default value unnecessarily declared for a 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.

Example

The following is an example of how this issue could look in your API definition:

1post:
2  description: Creates a new pet in the store
3  operationId: addPet
4  parameters:
5    - name: pet
6      in: body
7      description: pet to add to the system
8      required: true
9      schema:
10        type: object
11        required:
12          - name
13        properties:
14          name:
15            type: string
16            default: Fido
17          # ...
18

Remediation

Make sure that you do not specify default responses for required parameters.

1post:
2  description: Creates a new pet in the store
3  operationId: addPet
4  parameters:
5    - name: pet
6      in: body
7      description: pet to add to the system
8      required: true
9      schema:
10        type: object
11        required:
12          - name
13        properties:
14          name:
15            type: string
16          # ...
17

Copyright 42Crunch 2021