OpenAPI Linter
Linter for OpenAPI definitions to check compliance to AEPs.
This repository contains a Spectral ruleset to check an OpenAPI document for conformance to the API Enhancement Proposals.
How to use the aep-openapi-linter
Section titled “How to use the aep-openapi-linter”Dependencies
Section titled “Dependencies”The Spectral Ruleset requires Node version 20 or later.
Install Spectral
Section titled “Install Spectral”npm i @stoplight/spectral-cli -g
You can specify the ruleset directly on the command line:
spectral lint -r https://raw.githubusercontent.com/aep-dev/aep-openapi-linter/main/spectral.yaml <api definition file>
Or you can create a Spectral configuration file (.spectral.yaml) that
references the ruleset:
extends: - https://raw.githubusercontent.com/aep-dev/aep-openapi-linter/main/spectral.yamlExample
Section titled “Example”spectral lint -r https://raw.githubusercontent.com/aep-dev/aep-openapi-linter/main/spectral.yaml petstore.yamlUsing the Spectral VSCode extension
Section titled “Using the Spectral VSCode extension”There is a Spectral VSCode extension that will run the Spectral linter on an open API definition file and show errors right within VSCode. You can use this ruleset with the Spectral VSCode extension.
- Install the Spectral VSCode extension from the extensions tab in VSCode.
- Create a Spectral configuration file (
.spectral.yaml) in the root directory of your project as shown above. - Set
spectral.rulesetFileto the name of this configuration file in your VSCode settings.
Now when you open an OpenAPI document in this project, it should highlight lines with errors. You can also get a full list of problems in the file by opening the “Problems panel” with “View / Problems”. In the Problems panel you can filter to show or hide errors, warnings, or infos.
Contributing
Section titled “Contributing”See CONTRIBUTING for more details.