This rule checks all parameters in an OpenAPI schema and warns if they do not adhere to the specified naming convention.
The parameter-naming
rule is designed to ensure that each parameter in an
OpenAPI schema adheres to a specific naming convention. The recognised naming
conventions are:
const
- THIS_IS_CONST_CASEcamel
- thisIsCamelCasekebab
- this-is-kebab-casepascal
- ThisIsPascalCaseheader
- This-Is-Header-Casesnake
- this_is_snake_caseIt is possible to configure the naming convention separately for each parameter location. The default values are:
kebab
header
snake
The configuration block can be a string or an object.
If it is a string, its value is intepreted as the default naming convention, and is used for all parameter types.
If it is an object, it must contain the default
property, and may contain
any of the path
, query
, header
and cookie
properties. Value of each
property is the naming convention name (see the “Rule Details” section for
a list of recognized names). Value of the default
property is used as a
default naming convention, and values from other properties override naming
convention for specific parameter types.
Configuration Example 1. The following two examples are equivalent. They specify that
the expected naming convention for all parameters is PascalCase
.
lint:
rules:
parameter-naming:
- warning
- pascal
lint:
rules:
parameter-naming:
- warning
- default: pascal
Configuration Example 2. This configuration specifies sets the default naming convention
to be snake
, and overrides it for query parameters with kebab
, as well as
for header parameters with header
.
lint:
rules:
parameter-naming:
- warning
- default: snake
query: kebab
header: header
None.
We recommend to always enable this rule.
This rule is compatible with all OpenAPI 3.x versions.