How to solve "error #1: Invalid ruleset provided" when using Spectral to lint an OpenAPI YAML file

280 Views Asked by At

I am trying to lint an OpenAPI YAML file using Stoplight Spectral, and following the instructions provided here I get the error "error #1: Invalid ruleset provided" but not any other details.

2

There are 2 best solutions below

3
Gedeon On

This step:

echo 'extends: ["spectral:oas", "spectral:asyncapi"]' > .spectral.yaml

encloses the contents in quotes in the generated .spectral.yaml file, which causes the error. Removing the quotes will leave the value as:

extends: ["spectral:oas", "spectral:asyncapi"]

which is then understood by Spectral and eliminates the cause of the error.

NOTE: this is one of many possible error causes, rulesets themselves might have other internal issues.

0
Sajan Alex On

If you use Windows Power Shell CD to the npm folder where Spectral installed. Run as admin if there are errors showing and execute the command .\spectral lint [OpenAPI file path] --ruleset [ruleset file path] Eg. .\spectral lint C:\Path\openapi.yaml --ruleset C:\Path\spectral.yml