Review the OpenAPI media type prefix

Use a valid media type for the actual body format.

Description

OpenAPI 3.0 content keys identify media types or allowed media ranges. Misspelling a type such as application/json can prevent tools and API consumers from understanding the intended body format.

Potential impact

An incorrect type name can disrupt request or response interpretation and client generation. Renaming it in the document does not change the actual body format.

Remediation

Check the type and subtype spelling against the actual body format. Preserve valid vendor types or permitted media ranges rather than arbitrarily replacing them with generic types, and verify that the documented format matches the actual Content-Type.

Examples

These examples compare the JSON media type name in a reusable response. Operations that use this response must reference it separately.

Before

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0",
    "contact": {
      "name": "contact",
      "url": "https://www.google.com/",
      "email": "user@gmail.c"
    }
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "ResponseExample": {
        "description": "200 response",
        "content": {
          "applicasdsadtion/json": {
            "schema": {
              "properties": {
                "code": {
                  "type": "string",
                  "format": "binary"
                },
                "message": {
                  "type": "string"
                }
              },
              "type": "object"
            }
          }
        }
      }
    }
  }
}

After

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0",
    "contact": {
      "name": "contact",
      "url": "https://www.google.com/",
      "email": "user@gmail.c"
    }
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response",
            "content": {
              "application/json": {
                "examples": {
                  "foo": {
                    "value": {
                      "versions": [
                        {
                          "status": "CURRENT",
                          "updated": "2011-01-21T11:33:21Z",
                          "id": "v2.0",
                          "links": [
                            {
                              "href": "http://127.0.0.1:8774/v2/",
                              "rel": "self"
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "ResponseExample": {
        "description": "200 response",
        "content": {
          "application/json": {
            "schema": {
              "properties": {
                "code": {
                  "type": "string",
                  "format": "binary"
                },
                "message": {
                  "type": "string"
                }
              },
              "type": "object"
            }
          }
        }
      }
    }
  }
}

The revised response uses application/json instead of the misspelled applicasdsadtion/json. It does not include encoding settings that do not apply to a JSON response.

References