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).
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.
None.
Good.
components:
schemas:
UserStatus:
type: string
enum:
- active
- inactive
Bad.
components:
schemas:
UserStatus:
type: string
enum:
- 1
- 2
We recommend to always enable this rule.
This rule is compatible with all OpenAPI 3.x versions.