Spectral offers similar linting capabilities to Redocly CLI and the rest of the Redocly tools. This guide lays out the differences so you can switch tools if you want to.
The first step is to install Redocly CLI.
spectral lint openapi.yaml with the equivalent
redocly lint openapi.yaml
For more information, check out the
lint command documentation.
-r, use the
--extends parameter to indicate which ruleset you are using as a basis.
Read more about linting and rulesets
Similar to Spectral, Redocly offers multiple output formats using the
If you use
--resolver to handle how links and remote URLs are resolved, visit the configuration documentation to see how to handle this with Redocly.
The configuration formats are a little different between the tools.
Redocly uses a configuration file called
redocly.yaml, the main controls for linting are:
- Specify a ruleset.
- Add configuration for the rules accordingly. They can be set to error, warn, or off.
- Expand the collection with any configurable rules that fit your standard.
Below is an example of a
redocly.yaml configuration file, enabling the minimal ruleset, disabling the
security-defined rule, and setting up an example configurable rule to check for the word "test" appearing in an operation summary.
extends: - minimal rules: security-defined: off rule/naming: subject: type: Operation property: summary assertions: notPattern: /test/ message: "Operation summary must not include the word test"
It is also possible to configure additional rules for specific APIs using the APIs object to set per-API rules (or exceptions!).
Included here is an attempt to map the simliar-but-not-identical naming of rules between the tools. If you spot anything that needs adding or updating, please tell us?
If the built-in rules don't meet your requirements, don't worry! Redocly allows you to build any rule to meet your needs, using configurable rules. Declare which elements of the OpenAPI description should comply with the rule, and then define the criteria that it should be checked against.
Build up the rulesets that work for your organization's API standards. These can be:
- using existing Redocly rulesets
- defining your own rulesets from built-in, configurable and/or custom rules
- combining rulesets from any source
- adding per-API additions or exceptions as required
- using an ignore file to overlook existing/historic incompatibilities while still enforcing rules for changed elements
Redocly CLI supports multiple Redocly products and functions, so go ahead and read more about Redocly CLI.