Target of the JSON reference of the request body does not exist

Issue ID: v3-validation-reference-requestbody-unresolved

Description

The target of the JSON reference of the request body cannot be found in your API. You must define the target request body in your API.

Example

The following is an example of how this issue could look in your API definition. The name used in the reference does not match the name of the request body:

{
    "post": {
        "description": "Add a new pet",
        "requestBody": {
            "$ref": "#/components/requestBodies/petReqBody"
        }
    },
    // ...
    "components": {
        "requestBodies": {
            "petRequestBody": {
                "description": "A JSON object for reusable request body containing the details of a pet",
                "required": true,
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Pet"
                        }
                    }
                }
            }
        }
    }
}

Remediation

Make sure that all targets of JSON references are defined in your API.

{
    "post": {
        "description": "Add a new pet",
        "requestBody": {
            "$ref": "#/components/requestBodies/petRequestBody"
        }
    },
    // ...
    "components": {
        "requestBodies": {
            "petRequestBody": {
                "description": "A JSON object for reusable request body containing the details of a pet",
                "required": true,
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Pet"
                        }
                    }
                }
            }
        }
    }
}