Files
redocly-cli/docs/rules/no-server-variables-empty-enum.md
Adam Altman 9b1239c6d9 fix: rename rule no-empty-enum-servers to no-server-variables-empty-enum (#813)
* fix: rename rule no-empty-enum-servers to no-server-variables-empty-enum
- fix no-server-example.com docs

* chore: fix snapshots

Co-authored-by: Andrew Tatomyr <andrew.tatomyr@redocly.com>
2022-08-18 08:07:10 -05:00

1.8 KiB

redirectFrom
redirectFrom
/docs/cli/rules/no-empty-enum-servers/

no-server-variables-empty-enum

Disallow server variables without enum list defined.

OAS Compatibility
2.0
3.0
3.1
flowchart TD

root ==> ServersList --> Server --> ServerVariables

style ServerVariables fill:#codaf9,stroke:#0044d4,stroke-width:5px

API design principles

If you use server variables, there are generally two kinds:

  • tenant-driven
  • environment-driven

In the case of environment-driven variables, you may want to predefine all of the possible values.

Configuration

Option Type Description
severity string Possible values: off, warn, error. Default error (in recommended configuration).

An example configuration:

styleguide:
  rules:
    no-server-variables-empty-enum: error

Examples

Given this configuration:

styleguide:
  rules:
    no-server-variables-empty-enum: error

Example of incorrect server variables:

servers:
  - url: 'https://{env}.example.com/api/v1'
    variables:
      env:
        default: api
        description: Environment

Example of correct server:

servers:
  - url: 'https://{env}.example.com/api/v1'
    variables:
      env:
        default: api
        description: Environment
        enum:
          - api
          - sandbox
          - qa
          - test
          - dev

Resources