Score APIs in CI
Use a quality threshold to detect documentation regressions while checking that the report contains enough evidence to grade.
Preview: this workflow requires a compatible CLI build and Elva service support. Check elva --version and the command's --help output before using these examples. An older installed release may not include these commands.
elva insights checks --category Security
elva insights review openapi.yaml
cat openapi.yaml | elva --json insights review - --fail-under 80
elva insights show "Orders API" --fail-under 80
File and stdin reviews submit the specification to Elva without requiring an account; the CLI review limit is 2 MiB. Reviewing a stored collection requires workspace authentication. Remove secrets and private example data before submitting a spec.
set -euo pipefail
elva --json insights review openapi.yaml --fail-under 80 > review.json
python3 - <<'PY'
import json
with open("review.json") as stream:
report = json.load(stream)
if not report["scorable"]:
raise SystemExit("Specification is not scorable")
print("Quality gate passed:", report["overallScore"])
PY
Pin the CLI version used by your build and keep the spec file in the checked-out workspace. Store review.json as a build artifact. With --fail-under, a score below the threshold or an unscorable report exits with code 4. Without a threshold, a completed unscorable report can exit successfully, so check scorable explicitly.
Exit code | Meaning |
0 | Command completed successfully. |
1 | Unexpected local error. |
2 | Invalid usage or a command conflict. |
3 | Authentication is missing or invalid. |
4 | Validation failure or failed quality gate. |
5 | API, transport, or incomplete-job failure. |
130 | Interrupted command. |
Inspect stderr on failure. A transport error is not a passing quality gate. For unscorable reports, inspect unscorableReason, operationCount, rubricCoverage, and check comments; resolve missing operations or references before rerunning.
On this page
- Score APIs in CI