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"
    }
  }
}

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