From 0f8cc997cf253cdd896a6cd053dcfb91eb1f49b1 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Sun, 8 Jun 2025 07:52:13 -0400 Subject: [PATCH] gh actions: Use Spectral CLI to validate auth Swagger API spec Installs @stoplight/spectral-cli into the CI image, and uses it to validate the Swagger API spec against the Swagger 2.0 schema. --- .github/actions/spell-check/excludes.txt | 1 + docs/http-api/swagger/authoritative-api-swagger.yaml | 1 - docs/http-api/swagger/spectral-ruleset.yaml | 1 + tasks.py | 2 ++ 4 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 docs/http-api/swagger/spectral-ruleset.yaml diff --git a/.github/actions/spell-check/excludes.txt b/.github/actions/spell-check/excludes.txt index 9670cbaa59..587a8e61fb 100644 --- a/.github/actions/spell-check/excludes.txt +++ b/.github/actions/spell-check/excludes.txt @@ -94,6 +94,7 @@ SUMS$ ^codedocs/doxygen\.conf$ ^docs/depfile\.py$ ^docs/http-api/tsigkey\.rst$ +^docs/http-api/swagger/spectral-ruleset\.yaml$ ^docs/lua-records/reference/index\.rst$ ^modules/remotebackend/example\.rb$ ^modules/remotebackend/test-remotebackend-keys\.hh$ diff --git a/docs/http-api/swagger/authoritative-api-swagger.yaml b/docs/http-api/swagger/authoritative-api-swagger.yaml index 0be561ce52..83bad1fc3f 100644 --- a/docs/http-api/swagger/authoritative-api-swagger.yaml +++ b/docs/http-api/swagger/authoritative-api-swagger.yaml @@ -1104,7 +1104,6 @@ paths: required: true description: The length of the network prefix - name: view - type: string required: true description: The name of the view to use for to this network in: body diff --git a/docs/http-api/swagger/spectral-ruleset.yaml b/docs/http-api/swagger/spectral-ruleset.yaml new file mode 100644 index 0000000000..d47c47d315 --- /dev/null +++ b/docs/http-api/swagger/spectral-ruleset.yaml @@ -0,0 +1 @@ +extends: ["spectral:oas"] diff --git a/tasks.py b/tasks.py index f37ee06984..955a98b3a5 100644 --- a/tasks.py +++ b/tasks.py @@ -1196,10 +1196,12 @@ def test_bulk_recursor(c, size, threads, mthreads, shards, ipv6): @task def install_swagger_tools(c): + c.run('npm install -g @stoplight/spectral-cli') c.run('npm install -g api-spec-converter') @task def swagger_syntax_check(c): + c.run('spectral lint --ruleset docs/http-api/swagger/spectral-ruleset.yaml --fail-severity error --display-only-failures docs/http-api/swagger/authoritative-api-swagger.yaml') c.run('api-spec-converter docs/http-api/swagger/authoritative-api-swagger.yaml -f swagger_2 -t openapi_3 -s json -c') @task -- 2.47.2