no-enum-type-mismatch
Requires that the contents of every enum
value in your API description conform to the corresponding schema's specified type
.
OAS | Compatibility |
---|---|
2.0 | ✅ |
3.0 | ✅ |
3.1 | ✅ |
API design principles
If a property is defined for a certain type, then its corresponding enum
values should comply with that type. Lack of compliance is most likely the result of a typo.
Configuration
Option | Type | Description |
---|---|---|
severity | string | Possible values: off , warn , error . Default error (in recommended configuration). |
An example configuration:
rules:
no-enum-type-mismatch: error
Examples
Given this configuration:
rules:
no-enum-type-mismatch: error
Example of incorrect enum values given the enum type:
properties:
huntingSkill:
type: string
description: The measured skill for hunting
enum:
- adventurous
- 12
- 3.14
Example of correct enum values given the enum type:
properties:
huntingSkill:
type: string
description: The measured skill for hunting
enum:
- adventurous
- aggressive
- passive
Related rules
- configurable rules
- no-invalid-media-type-examples
- no-invalid-parameter-examples
- no-invalid-schema-examples