schema-property-naming

Since 0.0.1 · In the rulesets: Strict at error, All at error

This rule checks that the property names of schemas follow one naming convention, snake_case (first_name) unless configured otherwise.

Rule details

Property names are typed by every client, and a client author who has seen one should be able to spell the next. 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 property '...' is not in the '...' convention. It is in the strict and all rulesets.

Configuration

A convention name. snake_case by default.

Configuration example. Camel-case properties.

commands:
  lint:
    rules:
      schema-property-naming:
        - warning
        - camelCase

Examples

Good. With the default convention.

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

Bad. Camel case with the default convention.

components:
  schemas:
    User:
      type: object
      properties:
        firstName:
          type: string
        lastName:
          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.rules has the details.

commands:
  lint:
    rules:
      schema-property-naming: off
Last updated on View as Markdown
Was this helpful?