A human-readable version of the API Guidelines at Entur can be found here. The rest of this document describes how to do automatic checks on your API using a linter.
By "linting your API", we mean linting the OpenAPI specification of your API. This is done using Spectral with the Entur linting rules.
Using npm:
npm install -g @stoplight/spectral-cli
Or using yarn:
yarn global add @stoplight/spectral-cli
spectral lint api-spec.json --ruleset https://raw.githubusercontent.com/entur/api-guidelines/refs/tags/v0.1.0/.spectral.yml
Spectral Linter for Intellij : No good plugin seems to exist yet.
Git hooks are programs or commands you can set up and have them run when you commit or push.
Here's an example of a Spectral Git hook using Husky:
{
"husky": {
"hooks": {
"pre-commit": "spectral lint specs/*.{json,yml,yaml} --ruleset https://raw.githubusercontent.com/entur/api-guidelines/refs/tags/v0.1.0/.spectral.yml",
"pre-push": "spectral lint specs/*.{json,yml,yaml} --ruleset https://raw.githubusercontent.com/entur/api-guidelines/refs/tags/v0.1.0/.spectral.yml",
"...": "..."
}
}
}