schema-format-defined

schema-format-defined

This rule ensures that every schema object that is a string or a number has its format defined.

Rule Details

Defining the format of a string or numeric schema objects enhances the readability and understanding of the API’s structure.

The schema-format-defined rule is designed to ensure that all schema objects those type is string, number or integer have also format property defined.

Configuration

None.

Examples

Good. Now it is obvious that birthDate is a ISO8601 date string.

components:
  schemas:
    User:
      type: object
      properties:
        birthDate:
          type: string
          format: date

Bad. It is not immediately obvious how birthDate is formated. Is it YYYY-MM-DD or DD-MM-YY, or perhaps YY/MM/DD ?

components:
  schemas:
    User:
      type: object
      properties:
        birthDate:
          type: string

When Not to Use It

We recommend to always enable this rule.

Compatibility

This rule is compatible with all OpenAPI 3.x versions.

← Back to Index