Server object variable used in the server URL is not defined in the server object variables

Issue ID: v3-semantic-server-variables-undefined

Description

The variable you are using in the URL is not defined in the server variables in your API. All variables used in the url property must be defined as a key in the variables property map of the server object.

For more details, see the OpenAPI Specification.

Example

The following is an example of how this issue could look in your API definition. The variable username is used in the URL, but it has not been defined in the variables map:

{
    "servers": [
        {
            "url": "https://{username}.gigantic-server.com:{port}/{basePath}",
            "description": "The production API server",
            "variables": {
                "port": {
                    "enum": [
                        "8443",
                        "443"
                    ],
                    "default": "8443"
                },
                "basePath": {
                    "default": "v2"
                }
            }
        }
    ]
}

Remediation

Make sure that you have defined all variables used in URLs in the variables map of a server object.

{
    "servers": [
        {
            "url": "https://{user-name}.gigantic-server.com:{port}/{basePath}",
            "description": "The production API server",
            "variables": {
                "username": {
                    "default": "demo",
                    "description": "this value is assigned by the service provider, in this example `gigantic-server.com`"
                },
                "port": {
                    "enum": [
                        "8443",
                        "443"
                    ],
                    "default": "8443"
                },
                "basePath": {
                    "default": "v2"
                }
            }
        }
    ] 
}