Target of the JSON reference of the security scheme does not exist

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

Description

The target of the JSON reference of the security scheme cannot be found in your API. You must define the target link in your, and the name used in the reference must match to a security scheme you have defined the reusable security schemes.

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 security scheme:

{
    "components": {
        "securitySchemes": {
            "APIkey": {
                "type": "apiKey",
                "name": "X-API-Key",
                "in": "header"
            },
            "MyOAuth": {
                "$ref": "#/components/securitySchemes/OAuthCode"
            },
            //...
            "OAuth": {
                "type": "oauth2",
                "flows": {
                    "authorizationCode": {
                        "authorizationUrl": "https://example.com/api/oauth/dialog",
                        "tokenUrl": "https://example.com/api/oauth/token",
                        "scopes": {
                            "write:pets": "modify pets in your account",
                            "read:pets": "read your pets"
                        }
                    }
                }
            }
        }
    }
}

Remediation

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

{
    "components": {
        "securitySchemes": {
            "APIkey": {
                "type": "apiKey",
                "name": "X-API-Key",
                "in": "header"
            },
            "MyOAuth": {
                "$ref": "#/components/securitySchemes/OAuth"
            },
            //...
            "OAuth": {
                "type": "oauth2",
                "flows": {
                    "authorizationCode": {
                        "authorizationUrl": "https://example.com/api/oauth/dialog",
                        "tokenUrl": "https://example.com/api/oauth/token",
                        "scopes": {
                            "write:pets": "modify pets in your account",
                            "read:pets": "read your pets"
                        }
                    }
                }
            }
        }
    }
}