schema-enum-naming
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(alsoUPPER_CASEandSCREAMING_SNAKE_CASE):THIS_IS_CONST_CASEcamelCase:thisIsCamelCase, acronyms allowed (userID)camelCaseStrict:thisIsCamelCase, no two capitals in a row (userId)kebab-case:this-is-kebab-casePascalCase:ThisIsPascalCase, acronyms allowed (HTTPServer)PascalCaseStrict:ThisIsPascalCase, no two capitals in a row (HttpServer)Header-Case:This-Is-Header-Casesnake_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.
commands:
lint:
rules:
schema-enum-naming:
- warning
- kebab-case
Examples
Good. With the default convention.
components:
schemas:
UserStatus:
type: string
enum:
- ACTIVE
- INACTIVE
- BLOCKED
Bad. Three conventions in one enum.
components:
schemas:
UserStatus:
type: string
enum:
- activeStatus
- inactive_status
- BLOCKED_STATUS
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.rules has the details.
commands:
lint:
rules:
schema-enum-naming: off