Skip to content

openapi

OpenAPI documents: the committed document passes its lint rules and matches what its generator writes.

A scope has filenames openapi.yaml, openapi.yml, openapi.json, swagger.json, swagger.yaml, or swagger.yml.

Lints the file in openapi.document with the Spectral OpenAPI rules and the OWASP rules on credentials in URLs, HTTP Basic auth, and insecure auth schemes.

Runs at the commit stage, once per scope. It skips until you set openapi.document.

Teams generate clients from this document, so an operation with no ID or an undefined response breaks them.

Change the document the way the rule says, or the code that writes it.

An operation that references an undefined schema reports a finding. Define the schema or fix the reference in the source, then generate the document again.

gspot ignore openapi/spectral --paths "<path>" --reason "<why>"
gspot ignore openapi/spectral --rule <rule> --reason "<why>"

Runs openapi.generate_command and fails when the document changes.

Runs at the push stage, once per scope, with the command in openapi.generate_command, and loads your code. It skips until you set openapi.generate_command.

A committed document that lags the routes describes a service that does not exist.

Run the command and commit the document it writes.

A committed document that differs from the generator output reports drift. Run the generator, review the change, and commit it.

Rule What it checks What to do
stale Each committed file holds what the generator command writes now. Run the generator command, and commit the new file after you read the diff.
missing Each file that the check compares with the generator output exists. Run the generator command, then add the file to Git.
untracked Git tracks each file that the generator writes. Add the file with git add, and commit it.
gspot ignore openapi/stale-document --paths "<path>" --reason "<why>"
gspot ignore openapi/stale-document --rule stale --reason "<why>"
Setting What it sets
openapi.document The committed OpenAPI document, which init fills in when it finds one; without it, the OpenAPI checks do not run.
openapi.generate_command The command that writes the OpenAPI document from the code, run in the folder of the scope.
Rule file Installed when
.gspot/rules/OPENAPI.md Always
Tool Version
spectral 6.17.0
@stoplight/spectral-owasp-ruleset 2.0.1
ajv 8.20.0

.gspot/configurations/openapi/spectral.yml