How can I use custom linting with Inso CLI?
Create your .spectral.yaml
file in the same directory as the OAS file to lint, then run the inso lint spec
command.
In your Git repository, add a .spectral.yaml
file containing your custom ruleset at the same level as the .insomnia
folder.
For this task, you need a design document in Insomnia. We’ll use the KongAir Flights Service specification.
Click the button below to import the specification as a design document in Insomnia.
A new Flights Service 0.1.0 document is created.
This example requires a workspace synchronized with Git.
In the Git repository connected to your document, create a .spectral.yaml
at the same level as the .insomnia
folder.
The custom ruleset overrides the default one. If you want to create a completely new ruleset, you can simply add your rules in the file using the Spectral syntax. If you want to extend an existing ruleset, specify the ruleset with the extend
property in .spectral.yaml
.
For example, if you want to extend the default Spectral OpenAPI ruleset to add a warning when tags don’t have a description, you can add the following content to .spectral.yaml
:
extends: spectral:oas
rules:
tag-description:
description: Tags must have a description.
given: $.tags[*]
severity: warn
then:
field: description
function: truthy
Commit and push the file on the repository, then pull the changes in Insomnia.
Close and reopen the document to apply the changes. In this example, you can validate by creating a new tag without a description:
tags:
- name: flight-data
This causes a new warning to appear:
How can I use custom linting with Inso CLI?
Create your .spectral.yaml
file in the same directory as the OAS file to lint, then run the inso lint spec
command.