schema-property-naming
Since 0.9.0 · In the rulesets: Strict at error, All at error
This rule ensures that the names of schema properties adhere to a predefined naming convention.
Rule details
Property names are typed by every consumer, and one convention lets a consumer who has seen one name spell the next; it also maps messages to the data structures of one language without renaming.
The schema-property-naming rule checks the keys of the properties map of
every schema of an AsyncAPI document. For every property whose name is not in
the expected convention, it reports
Schema property '<name>' is not in the '<convention>' convention.
The recognised naming conventions are:
CONST_CASE(alsoUPPER_CASEandSCREAMING_SNAKE_CASE) - THIS_IS_CONST_CASEcamelCase- thisIsCamelCase, also with acronyms (userID)camelCaseStrict- thisIsCamelCase, but no two capitals in a row (userId, not userID)kebab-case- this-is-kebab-casePascalCase- ThisIsPascalCase, also with acronyms (HTTPServer)PascalCaseStrict- ThisIsPascalCase, but no two capitals in a row (HttpServer, not HTTPServer)Header-Case- This-Is-Header-Casesnake_case- this_is_snake_case
The default convention is snake_case.
Turn the rule off when the API follows no naming convention for schema properties.
Configuration
The configuration block is a naming convention name (see the “Rule details” section for a list of recognized names).
version: "1.0"
commands:
lint:
asyncapi:
rules:
schema-property-naming: [error, camelCase]
Examples
Good. With the default configuration.
asyncapi: 3.0.0
info:
title: User Events
version: 1.0.0
components:
schemas:
UserSignedUp:
type: object
properties:
user_id:
type: string
display_name:
type: string
Bad. With the default configuration.
asyncapi: 3.0.0
info:
title: User Events
version: 1.0.0
components:
schemas:
UserSignedUp:
type: object
properties:
userId:
type: string
DisplayName:
type: string
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.asyncapi has the details.
commands:
lint:
asyncapi:
rules:
schema-property-naming: off