# schema-property-naming

Source: https://api-genie.dev/docs/linter/openapi/rules/schema-property-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 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.

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

## Examples

**Good**. With the default convention.

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

**Bad**. Camel case with the default convention.

```yaml
components:
  schemas:
    User:
      type: object
      properties:
        firstName:
          type: string
        lastName:
          type: string
```
