diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 3691363..1bf7004 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -85,6 +85,22 @@ language: script files: \.go$ ###################### +# OpenAPI related hooks +- id: openapi-lint + name: "openapi-lint: Lint OpenAPI specifications" + description: Runs Spectral linting against OpenAPI specification files + args: [ + lint, + spec/**/*.yaml, + --fail-severity=warn, + --ignore-unknown-format=true, + ] + entry: spectral + files: ^spec/ + language: node + types: [yaml] + additional_dependencies: ["@stoplight/spectral-cli"] +###################### # Yaml related hooks # These only have shell dependencies - id: yaml-extension diff --git a/README.md b/README.md index bbfe9cd..828580e 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,10 @@ The following hooks are available: - **docker-compose-lint** (_requires docker_) - Runs docker-compose config on compose files +**OpenAPI** + +- **openapi-lint** - Runs Spectral linting against API specs. + ### Example A typical `pre-commit-config.yaml` for a Golang project would look like this: