Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turo/devops, if anyone has any suggestions, I'd really like the directory containing specs to not be specified here but by the repo that uses the pre-commit hook. I haven't yet figured out a way to do that.

--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
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down