Linter rulesOpenAPIschema-enum-no-duplicates
schema-enum-no-duplicates
Since 0.0.1 · fixed by --fix
This rule ensures that schema objects do not have duplicate values in their
enum or const properties.
Rule Details
Duplicate values can lead to confusion and misinterpretation of the API’s structure.
The schema-enum-no-duplicates rule is designed to ensure that all schema
objects do not have duplicate values in their enum or const properties.
The rule works by iterating over all the schema objects and checking if their
enum or const properties have duplicate values. If a duplicate value
is found, the rule raises a warning.
Configuration
None.
Examples
Good.
components:
schemas:
UserStatus:
type: string
enum:
- active
- inactive
Bad.
components:
schemas:
UserStatus:
type: string
enum:
- active
- active
When Not to Use It
We recommend to always enable this rule.
Compatibility
This rule is compatible with all OpenAPI 3.x versions.