Skip to content

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.

The Spectral Ruleset requires:

You can use the aep-openapi-linter as an npm package or directly from GitHub.

If you choose to use it as an npm package, install it in your project as you would any other npm package:

Terminal window
npm install @aep_dev/aep-openapi-linter

To use the aep-openapi-linter, create a Spectral configuration file (.spectral.yaml) that references the ruleset. If you installed the aep-openapi-linter npm package into your project, you can just reference the ruleset by name:

extends:
- '@aep_dev/aep-openapi-linter'

Note that the quotes are required by yaml syntax.

You can also bypass installing the npm aep-openapi-linter package and reference the ruleset directly from GitHub:

extends:
- https://raw.githubusercontent.com/aep-dev/aep-openapi-linter/main/spectral.yaml

You can pin to a specific release of the ruleset by replacing main with the tag for the release. E.g.

extends:
- https://raw.githubusercontent.com/aep-dev/aep-openapi-linter/refs/tags/v0.5.1/spectral.yaml

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.

  1. Install the Spectral VSCode extension from the extensions tab in VSCode.
  2. Create a Spectral configuration file (.spectral.yaml) in the root directory of your project as shown above.
  3. Set spectral.rulesetFile to 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.

See CONTRIBUTING for more details.