schema-enum-types

schema-enum-types

This rule checks schema objects and warns if allowed schema values (from enum and const properties) are consistent with schema types (i.e. their type property).

Rule Details

Inconsistencies between allowed values and type can lead to confusion and misinterpretation of the API’s structure.

The schema-enum-types rule is designed to ensure that the allowed values of a schema object, as defined by its enum and const properties, are consistent with its type.

Configuration

None.

Examples

Good.

components:
  schemas:
    UserStatus:
      type: string
      enum:
        - active
        - inactive

Bad.

components:
  schemas:
    UserStatus:
      type: string
      enum:
        - 1
        - 2

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