Want to check an OpenAPI description against recommended rules?
Recommended OpenAPI rules are the default behavior when vacuum lints an OpenAPI document. AsyncAPI documents use AsyncAPI Recommended Rules.
To explicitly define a ‘recommended only’ ruleset that can be customized, it’s easy to extend a ruleset the same way that Spectral does.
Create a new file (something like recommended-rules.yaml) and add the following YAML to it:
extends: [[vacuum:oas, recommended]]
This creates a ruleset that extends OpenAPI ‘recommended’ rules. You can find this ruleset in the rulesets/examples directory, and it’s named recommended-ruleset.yaml
Now you can run any vacuum command that supports a ruleset.
Validation
The recommended ruleset checks the structure and relationships in your OpenAPI document.
- oas3-schema checks fields, types and permitted combinations.
- path-params checks path parameters and duplicate templates.
- oas3-document-relationships checks Link targets, tags and server variable defaults.
These rules report errors. To change a rule’s severity:
extends: [[vacuum:oas, recommended]]
rules:
oas3-document-relationships: warn
Use off to disable a rule. Each rule is configured separately.
Generating Recommended RuleSet.
To generate a complete RuleSet of every recommended rule and all the configurations used, vacuum contains a generate-ruleset command
that accepts an ‘recommended’ option. This command only generates YAML files.
Will generate ‘my-ruleset-recommended.yaml’ and will be a complete listing of every recommended rule available.