api-swift / scripts / fetch-spec.sh
118 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#!/bin/sh
# Refresh spec/openapi.json from the live API, kept single-line exactly as
# served (as in the clj, ts and cljs repos). Afterwards regenerate and test:
#   python3 scripts/gen-api.py && swift test
# The generator refuses any operation its name table does not know, and the
# coverage test compares IrdOperation.all against every operation in the spec,
# so the API gaining or losing endpoints fails loudly.
set -e
cd "$(dirname "$0")/.."
curl -fsSL https://api.ird.ro/openapi.json -o spec/openapi.json.tmp
python3 -c '
import json, sys
s = json.load(open(sys.argv[1]))
ops = sum(1 for p in s["paths"].values() for m in p if m in ("get", "post", "put", "patch", "delete"))
print("spec: %d paths, %d operations" % (len(s["paths"]), ops))
' spec/openapi.json.tmp
mv spec/openapi.json.tmp spec/openapi.json

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/api-swift.git