redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Assertions severity off is considered invalid

Open adamaltman opened this issue 2 years ago • 1 comments

Describe the bug

The value off isn't accepted but it is described as an acceptable severity level.

  • Invalid severity level; accepted values: error or warn.

It also results in a hard (not elegant) crash.

To Reproduce Steps to reproduce the behavior:

  1. Given this .redocly.yaml file with

        assert/properties-include-examples:
          subject: SchemaProperties
          property: example
          defined: true
          nonEmpty: true
          severity: off
    
  2. See error

Expected behavior

It should work with off. However, if there is a value someone didn't expect, then don't do a hard crash.

Logs

  - Invalid severity level; accepted values: error or warn.

/Users/adam/.nvm/versions/node/v16.10.0/lib/node_modules/@redocly/cli/node_modules/@redocly/openapi-core/lib/format/format.js:148
            throw new Error(ERROR_MESSAGE.INVALID_SEVERITY_LEVEL);
                  ^

Error: Invalid severity level; accepted values: error or warn
    at getBgColor (/Users/adam/.nvm/versions/node/v16.10.0/lib/node_modules/@redocly/cli/node_modules/@redocly/openapi-core/lib/format/format.js:148:19)
    at formatCodeframe (/Users/adam/.nvm/versions/node/v16.10.0/lib/node_modules/@redocly/cli/node_modules/@redocly/openapi-core/lib/format/format.js:153:25)
    at Object.formatProblems (/Users/adam/.nvm/versions/node/v16.10.0/lib/node_modules/@redocly/cli/node_modules/@redocly/openapi-core/lib/format/format.js:71:41)
    at Object.<anonymous> (/Users/adam/.nvm/versions/node/v16.10.0/lib/node_modules/@redocly/cli/lib/commands/lint.js:52:36)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/adam/.nvm/versions/node/v16.10.0/lib/node_modules/@redocly/cli/lib/commands/lint.js:5:58)

OpenAPI definition If applicable, add an OpenAPI definition and .redocly.yaml configuration file that helps reproduce the problem. At a minimum, please state the specification version(s) you're using (e.g. 2.0, 3.0, 3.1).

Redocly Version(s) What version of Redocly CLI are you using?

Node.js Version(s) What version of node.js are you using?

Additional context Add any other context about the problem here.

adamaltman avatar May 24 '22 02:05 adamaltman

Raising priority so that docs can be simplified.

adamaltman avatar Jul 25 '22 21:07 adamaltman