schema-enum-naming

schema-enum-naming

This rule ensures that all string values defined in enum or const properties of schema objects adhere to a predefined naming convention.

Rule Details

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

The schema-enum-naming rule is designed to ensure that all string values defined in enum or const properties of schema objects adhere to a predefined naming convention. Currently supported naming conventions are const, camel, kebab, pascal, header, and snake.

Configuration

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

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

Examples

Good.

components:
  schemas:
    UserStatus:
      type: string
      enum:
        - ACTIVE
        - INACTIVE
        - BLOCKED

Bad. To use UsesStatus properly, a user must always consult the documentation.

components:
  schemas:
    UserStatus:
      type: string
      enum:
        - activeStatus
        - inactive_status
        - BLOCKED_STATUS
        - blocked_status

When Not to Use It

If your API does not follow a specific naming convention for enum or const values in its schema objects, you may not need to use this rule.

Compatibility

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

← Back to Index