openapi
OpenAPI documents: the committed document passes its lint rules and matches what its generator writes.
Selected when
Section titled “Selected when”A scope has filenames openapi.yaml, openapi.yml, openapi.json, swagger.json, swagger.yaml, or swagger.yml.
Checks
Section titled “Checks”spectral
Section titled “spectral”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.
What to do
Section titled “What to do”Change the document the way the rule says, or the code that writes it.
Example
Section titled “Example”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.
Turn it off
Section titled “Turn it off”gspot ignore openapi/spectral --paths "<path>" --reason "<why>"gspot ignore openapi/spectral --rule <rule> --reason "<why>"stale-document
Section titled “stale-document”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.
What to do
Section titled “What to do”Run the command and commit the document it writes.
Example
Section titled “Example”A committed document that differs from the generator output reports drift. Run the generator, review the change, and commit it.
Lint rules
Section titled “Lint rules”| 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. |
Turn it off
Section titled “Turn it off”gspot ignore openapi/stale-document --paths "<path>" --reason "<why>"gspot ignore openapi/stale-document --rule stale --reason "<why>"Settings
Section titled “Settings”| 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. |
Rules for coding agents
Section titled “Rules for coding agents”| Rule file | Installed when |
|---|---|
.gspot/rules/OPENAPI.md |
Always |
Tools and versions
Section titled “Tools and versions”| Tool | Version |
|---|---|
| spectral | 6.17.0 |
| @stoplight/spectral-owasp-ruleset | 2.0.1 |
| ajv | 8.20.0 |
Files gspot writes
Section titled “Files gspot writes”.gspot/configurations/openapi/spectral.yml