parameter-naming

parameter-naming

This rule checks all parameters in an OpenAPI schema and warns if they do not adhere to the specified naming convention.

Rule Details

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:

It is possible to configure the naming convention separately for each parameter location. The default values are:

Configuration

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

Examples

None.

When Not to Use It

We recommend to always enable this rule.

Compatibility

This rule is compatible with all OpenAPI 3.x versions.

← Back to Index