415 response should be defined for operations receiving a body (POST, PUT, PATCH)

Description

One or more POST, PUT, and PATCH operations are missing 415 responses. All operations that receive a body should have 415 responses defined.

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 store",
     ...
   ]
  },
  "responses": {
  "200": {
    "description": "pet response",
      "schema": {
        "type": "array",
        "items": {
          "$ref": "Pet.json"
        }
      }
    }
  }
}

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 415 responses for all POST, PUT, and PATCH operations.

"post": {
  "description": "Creates a new pet in the store",
  "operationId": "addPet",
  "parameters": [
    {
      "name": "pet",
      "in": "body",
      "description": "Pet to add to the store",
     ...
   ]
  },
  "responses": {
    "200": {
     "description": "pet response",
      "schema": {
        "type": "array",
        "items": {
          "$ref": "Pet.json"
        }
      }
    }
   ...
   "415": {
     "description": "Unsupported media type"
    }
  }
}

Get API Security news directly in your Inbox.

By clicking Subscribe you agree to our Data Policy