Linter rulesOpenAPIschema-enum-types
schema-enum-types
Since 0.0.1 · fixed by --fix
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.
Automatic fixes
When invoked with --fix, a non-empty enum whose values all have one JSON type
sets the schema type to that type. Mixed-type enums and schemas with format
remain manual.
Compatibility
This rule is compatible with all OpenAPI 3.x versions.