Skip to content

Commit

Permalink
ci: openapi: Use vacuum to validate/lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjat committed Feb 22, 2024
1 parent 56da641 commit 16a2584
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,21 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Normalize YAML
- name: Install dependencies
run: |
VERSION=v4.30.5 BINARY=yq_linux_amd64
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O ./yq
VERSION=v4.30.5
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_amd64 -q -O ./yq
chmod +x ./yq
VERSION=0.9.9
wget https://github.com/daveshanley/vacuum/releases/download/v${VERSION}/vacuum_${VERSION}_linux_x86_64.tar.gz -q -O- | tar -xzv
- name: Normalize YAML
run: |
# OpenAPI parser fails to parse YAML templates (*, <<:). Expand them out here.
<api/spec/v1.yaml ./yq --output-format json | ./yq --output-format yaml --input-format json >api/spec/v1-normalized.yaml
- name: Validate OpenAPI definition
uses: char0n/swagger-editor-validate@v1
with:
definition-file: api/spec/v1-normalized.yaml
run: |
./vacuum lint --ruleset .vacuum.yaml --errors api/spec/v1-normalized.yaml
validate-migrations:
runs-on: ubuntu-20.04
Expand Down
7 changes: 7 additions & 0 deletions .vacuum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Config for vacuum, the openapi spec linter.

extends: [[spectral:oas, recommended]]
rules:
# This rule requires an operationId attribute for every endpoint.
# However, openapi spec says it's an optional attribute.
operation-operationId: false

0 comments on commit 16a2584

Please sign in to comment.