cljs / scripts / fetch-spec.sh
88 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/bin/sh
# Refresh spec/openapi.json from the live API, kept single-line exactly as
# served (as in the clj and ts repos). Afterwards run `npm test`: the coverage
# test compares its table against every operation in the spec and fails with
# the symmetric difference when the API gained or lost endpoints.
set -e
cd "$(dirname "$0")/.."
curl -fsSL https://api.ird.ro/openapi.json -o spec/openapi.json.tmp
node -e '
  const s = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"));
  const ops = Object.values(s.paths).flatMap(p =>
    Object.keys(p).filter(m => /^(get|post|put|patch|delete)$/.test(m)));
  console.log(`spec: ${Object.keys(s.paths).length} paths, ${ops.length} operations`);
' 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/cljs.git