# schema-enum-naming

Source: https://apigenie.pl/docs/linter/openapi/rules/schema-enum-naming

A rule of the OpenAPI linter, which reads OpenAPI 3.0, 3.1 and 3.2 documents. Since 0.0.1. In the rulesets: Strict at error, All at error.

This rule checks that the string values of `enum` and `const` follow one naming convention,
`CONST_CASE` (`ACTIVE_USER`) unless configured otherwise.

## Rule details

Enum values are spelled by clients, in code and in requests, so a client author who has seen one
should be able to spell the next. `activeStatus` next to `inactive_status` and `BLOCKED_STATUS`
needs a lookup for each. The conventions the rule knows:

- `CONST_CASE` (also `UPPER_CASE` and `SCREAMING_SNAKE_CASE`): `THIS_IS_CONST_CASE`
- `camelCase`: `thisIsCamelCase`, acronyms allowed (`userID`)
- `camelCaseStrict`: `thisIsCamelCase`, no two capitals in a row (`userId`)
- `kebab-case`: `this-is-kebab-case`
- `PascalCase`: `ThisIsPascalCase`, acronyms allowed (`HTTPServer`)
- `PascalCaseStrict`: `ThisIsPascalCase`, no two capitals in a row (`HttpServer`)
- `Header-Case`: `This-Is-Header-Case`
- `snake_case`: `this_is_snake_case`

The rule reports `Schema enum value '...' is not in the '...' convention`. It is in the `strict`
and `all` rulesets.

## Configuration

A convention name. `CONST_CASE` by default.

**Configuration example**. Kebab-case values.

```yaml
commands:
  lint:
    rules:
      schema-enum-naming:
        - warning
        - kebab-case
```

## Examples

**Good**. With the default convention.

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

**Bad**. Three conventions in one enum.

```yaml
components:
  schemas:
    UserStatus:
      type: string
      enum:
        - activeStatus
        - inactive_status
        - BLOCKED_STATUS
```
