Rulesets are collections of rules written in JSON, YAML, or JavaScript. Rulesets provide powerful linting of other JSON or YAML files, such as OpenAPI or AsyncAPI descriptions.
Ruleset files are often named .spectral.yaml, but that’s not a requirement.
Rules take certain parameters and then call functions on parts of another YAML or JSON object being linted.
Extend an Existing Ruleset
The fastest way to create a ruleset is to use the extends property to leverage an existing ruleset.
OpenLint includes built-in rulesets for OpenAPI, AsyncAPI, and Arazzo:
openlint:openapi- OpenAPI v2/v3 rulesopenlint:asyncapi- AsyncAPI v2/v3 rulesopenlint:arazzo- Arazzo v1 rules
The legacy spectral:* names remain available as compatibility spellings when their corresponding rulesets are available.
spectral:oas- Legacy OpenAPI v2/v3 rulesspectral:asyncapi- Legacy AsyncAPI v2/v3 rules from@openlint/ruleset-spectral-asyncapi(full compatibility ruleset)spectral:arazzo- Legacy Arazzo v1 rules from@openlint/ruleset-spectral-arazzo(full compatibility ruleset)
To create a ruleset that extends one or more of these rulesets open your terminal and run:
echo 'extends: ["openlint:openapi", "openlint:asyncapi", "openlint:arazzo"]' > .openlint.yamlThen OpenLint is ready to lint your documents.
openlint lint myapifile.yamlWrite Your First Rule
Here’s an example of a ruleset with a single rule:
rules: paths-kebab-case: description: Paths should be kebab-case. message: "{{property}} should be kebab-case (lower-case and separated with hyphens)" severity: warn given: $.paths[*]~ then: function: pattern functionOptions: match: "^(\/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$"The example rule validates an OpenAPI description by ensuring the paths properties uses kebab-case (lower-case and separated with hyphens).
Breaking down each part of the rule:
descriptionandmessagehelp users quickly understand what the goal of the rule isseverityhelp define the importance of following the rule- The
givenkeyword tells Spectral what part of the JSON or YAML file to target by using JSONPath (Spectral uses JSONPath Plus). - The
thenproperty includes thefunctiontype and options that tells Spectral how to apply the function to the JSON or YAML file, and make sure that the rule is being followed or not. Spectral has a set of built-in functions such astruthyorpattern, which can be used to power rules.
Next Steps
For more information about creating Rulesets and Rules, see Custom Rulesets.
For more examples of existing rulesets you can use, see Real-World Rulesets.
Last updated Nov 16, 2026