Key used in the encoding map of the schema is not defined in the properties of the schema
Issue ID: v3-semantic-mediatype-encoding-key-undefined
Description
The encoding map of a schema you have defined for a media type object contains a key that is not defined in the properties of the schema.
The encoding
property of a media type object maps the schema's property name to a specific encoding. All keys in the encoding map must be defined as properties in the schema.
For more details, see the OpenAPI Specification.
Example
The following is an example of how this type of risk could look in your API definition The key historyMetadata
in the encoding map has not been defined in the schema of the media type object:
{
"requestBody": {
"content": {
"multipart/mixed": {
"schema": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"address": {
"type": "object",
"properties": {}
},
"type": "object",
"properties": {}
},
"profileImage": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"historyMetadata": {
"contentType": "application/xml; charset=utf-8"
}
}
}
}
}
Remediation
Make sure that all keys in the encoding map are defined in the schema of the media type object.
{
"requestBody": {
"content": {
"multipart/mixed": {
"schema": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"address": {
"type": "object",
"properties": {}
},
"historyMetadata": {
"description": "metadata in XML format",
"type": "object",
"properties": {}
},
"profileImage": {
"type": "string",
"format": "binary"
}
}
},
"encoding": {
"historyMetadata": {
"contentType": "application/xml; charset=utf-8"
}
}
}
}
}
}