oasdiff

Given:

The task:

Why not just run diff and look at the differences?

The last point isn’t all that hard to solve with jq --sort-keys. A simple example:

diff \
    <(jo foo=1 bar=2 baz=3 | jq --sort-keys) \
    <(jo baz=4 foo=1 bar=2 | jq --sort-keys)
3c3
<   "baz": 3,
---
>   "baz": 4,

But it doesn’t make the main problem any faster or any easier.

What we need is to find or build a tool that shows the differences between two versions of the same spec in a human-readable format.

Fortunately, such solutions exist. Let’s take a quick look at the tools that made it into the survey.

redskap/swagger-brake 1

civisanalytics/swagger-diff 2

Sayi/swagger-diff 3

atlassian/openapi-diff 4

Tufin/oasdiff — ✅ 5

oasdiff was the one we picked as the primary tool for finding differences between OpenAPI contracts.

Here’s how to print a list of backwards-incompatible changes, for example:

oasdiff breaking \
    spec1.json \
    spec2.json

One last note: the move from one version to another is solved not just by understanding contract changes, but also by having a solid set of e2e tests.