From 16a258401fa00bef73462a8683d581ceee7dee58 Mon Sep 17 00:00:00 2001 From: Mitja T Date: Thu, 22 Feb 2024 12:02:39 -0800 Subject: [PATCH] ci: openapi: Use `vacuum` to validate/lint --- .github/workflows/ci-test.yaml | 16 ++++++++++------ .vacuum.yaml | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 .vacuum.yaml diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml index db3965f4f..adb503c6d 100644 --- a/.github/workflows/ci-test.yaml +++ b/.github/workflows/ci-test.yaml @@ -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-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 diff --git a/.vacuum.yaml b/.vacuum.yaml new file mode 100644 index 000000000..40d1b3ddf --- /dev/null +++ b/.vacuum.yaml @@ -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