schema-property-naming

schema-property-naming

This rule checks all schema objects and warns if any of them define properties whose names do not adhere to the specified naming convention.

Rule Details

Adhering to a consistent naming convention enhances the readability and maintainability of the API’s structure.

The schema-property-naming rule is designed to ensure that all properties defined in schema objects adhere to a specified naming convention. Currently recognised naming conventions are const, camel, kebab, pascal, header, and snake.

Configuration

The configuration block is a naming conventing name. Its default value is snake.

lint:
  rules:
    paths-max-count:
      - warning
      - kebab

Examples

Good.

components:
  schemas:
    User:
      type: object
      properties:
        firstName:
          type: string
        lastName:
          type: string

Bad.

components:
  schemas:
    User:
      type: object
      properties:
        first_name:
          type: string
        last_name:
          type: string

When Not to Use It

If your API does not follow a specific naming convention for schema property names, you may not need to use this rule.

Compatibility

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

← Back to Index