# schema-enum-types

Source: https://apigenie.pl/docs/linter/openapi/rules/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**.

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

**Bad**.

```yaml
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.
