KUBB_INVALID_SERVER_VARIABLE: Invalid server variable
Code: KUBB_INVALID_SERVER_VARIABLE
Level: error
A server variable resolves to a value that its enum does not allow.
What happened
OpenAPI server URLs can contain {variable} placeholders. When a variable declares an enum, the value Kubb resolves it to must be in that list. This diagnostic fires when the resolved value is not.
How to fix it
- Pass a value that the
enumallows, or make thedefaulta member of theenum. - Add the value to the
enumif the server supports it. - Remove the
enumif the variable is open-ended.
Common causes
- An override passed to Kubb uses a value outside the variable's
enum. - The variable's
defaultis not itself a member of itsenum. - The
enumlist is missing a value that the server actually supports.
Example
yaml
servers:
- url: https://{env}.api.example.com
variables:
env:
default: dev
enum: [dev, prod] # 'staging' is not allowedExample output
text
[KUBB_INVALID_SERVER_VARIABLE]: Invalid server variable value 'staging' for 'env' when resolving https://{env}.api.example.com. Valid values are: dev, prod.
at: #/servers
fix: Use one of the allowed enum values, or drop the enum on the 'env' server variable.
see: https://kubb.dev/docs/5.x/reference/diagnostics/kubb-invalid-server-variable