FAQ

  • GitHub GitHub Repo stars
  • Discord Discord Server
  • ✨ New! Try the OpenAPI Doctor ✨ The OpenAPI Doctor
    Recommended

    duplicated-entry-in-enum


    Formats: Severity:

    Enums allow API designers to define a pre-set list of values that are acceptable for input, or will be output.

    Sometimes, copy-pasta happens and Enums become duplicated.

    This rule checks every item is unique, in all enum values.

    Why did this violation appear?

    A value listed in an enum has been duplicated. Each value needs to be unique.

    Bad example

    paths:
      /items:
        get:
          parameters:
            - in: query
              name: sort
              description: "Sorting order for items"
              schema:
                type: string
                enum: [asc, desc, asc, asc]
                ...
    

    Good Example

    paths:
      /items:
        get:
          parameters:
            - in: query
              name: sort
              description: "Sorting order for items"
              schema:
                type: string
                enum: [asc, desc]
                ...
    

    How do I fix this violation?

    Check enum values for duplicated content.

    Spectral Equivalent

    The rule is equivalent to duplicated-entry-in-enum