# schema-datetime-suffix

Source: https://apigenie.pl/docs/linter/openapi/rules/schema-datetime-suffix

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

This rule checks that the name of every property with the `date`, `date-time` or `time` format
ends with `_at`, or with the suffix configured.

## Rule details

A reader of `created_at` knows it is a point in time without looking at the schema, and knows
that `created` next to it is something else, a flag perhaps. One suffix for every date and time
in the API makes the names say their type.

The rule looks at the properties of object schemas and reports `Property name ... should end with
...`.

## Configuration

A non-empty string: the suffix. `_at` by default. Pick the suffix that fits the naming convention
of your properties: `At` for camel case (`createdAt`), `_at` for snake case.

**Configuration example**. Camel-case properties.

```yaml
commands:
  lint:
    rules:
      schema-datetime-suffix:
        - warning
        - At
```

## Examples

**Good**. With the default suffix.

```yaml
components:
  schemas:
    User:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
```

**Bad**. Nothing in the name says it is a date.

```yaml
components:
  schemas:
    User:
      type: object
      properties:
        creation:
          type: string
          format: date-time
```
