No default response defined for the operation

Description

One or more operations in your API have no default response defined.

The default response is optional. It can be used as the default response object for all HTTP codes that are not covered individually by the API specification. It can also be used to cover undeclared responses. You can use a $ref object to link to a response that is defined in the global responses section.

Example

The following is an example of an API definition without the default section:

"responses": {
  "200": {
    "description": "Expected response to a valid request",
    "schema": {
      "$ref": "#/definitions/Pets"
    }
  }
}

Possible exploit scenario

Attackers strive to make your APIs behave in an unexpected way to learn more about your system or to cause a data breach. We highly recommend that you minimize any risks and clearly specify the data that your API operations can return for each possible response code.

Remediation

Define default responses for all API operations:

"responses": {
  "200": {
    "description": "Expected response to a valid request",
    "schema": {
      "$ref": "#/definitions/Pets"
    }
  },
  "default": {
    "description": "unexpected error",
    "schema": {
      "$ref": "#/definitions/Error"
    }
  }
}

Get API Security news directly in your Inbox.

By clicking Subscribe you agree to our Data Policy