Skip to content
Download

Check OpenAPI drift

kurlo openapi check tells CI when the API’s spec has moved on since a collection was last synced with it. It reads the collection’s OpenAPI source, downloads the current spec and compares it with openapi/spec.json, the spec of the last sync applied in Kurlo and committed next to collection.yml. It changes no files: apply the changes in the app and commit them.

Terminal window
kurlo openapi check "Pets API" --workspace ./api
kurlo openapi check --workspace ./api --env CI --var specToken="$SPEC_TOKEN"
kurlo openapi check "Pets API" --workspace ./api --spec ./build/openapi.json --reporter json

The output lists operations new in the spec, changed (parameters, request body, responses, security or description, with $refs followed), moved to another path under the same operationId, and removed, plus a change of servers. It also names requests in the collection that are not linked to any operation. x- extensions are ignored.

FlagMeaning
[collection], --collection <name>Collection to check. Optional when only one collection is synced.
--workspace <dir>Workspace directory (default .).
--spec <file>Compare with this file, for example one your build generated, instead of the collection’s source.
--env <name>, --env-file <path>, --var KEY=VALUEValues for {{variables}} in the source URL and its headers. Collection variables are used too.
--reporter cli|jsonText (default) or a JSON report.
--insecureSkip TLS certificate verification when downloading the spec.
Exit codeMeaning
0The spec matches the last sync.
1The spec changed.
2The check could not run: no such collection, no sync applied yet, an unset variable, or the spec could not be downloaded or read.