]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
gh actions: Use Spectral CLI to validate auth Swagger API spec 15643/head
authorKevin P. Fleming <kevin@km6g.us>
Sun, 8 Jun 2025 11:52:13 +0000 (07:52 -0400)
committerKevin P. Fleming <kevin@km6g.us>
Sun, 8 Jun 2025 12:06:30 +0000 (08:06 -0400)
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
docs/http-api/swagger/authoritative-api-swagger.yaml
docs/http-api/swagger/spectral-ruleset.yaml [new file with mode: 0644]
tasks.py

index 9670cbaa59d73b064e5fd5092f494c4d1ce89a1c..587a8e61fbf95b27bd16bdaa55bd9996775081ff 100644 (file)
@@ -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$
index 0be561ce52606211da249a6b7c5761b015b5bf9d..83bad1fc3f72d7e93f7b48b0c398133847616959 100644 (file)
@@ -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 (file)
index 0000000..d47c47d
--- /dev/null
@@ -0,0 +1 @@
+extends: ["spectral:oas"]
index f37ee069849039875f93b1a800e7011d01dc71a3..955a98b3a5a46ba88389e362ac9bdc64b2a82945 100644 (file)
--- 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