3[](https://hackage.haskell.org/package/compaREST)
4[](LICENSE)
6Compatibility checker for OpenAPI
8## Using compaREST in Github Actions
10Add the following step to your Github Actions workflow:
13- uses: typeable/comparest
14 if: ${{ github.event_name == 'pull_request' }}
20The `new` and `old` values should be paths to your OpenAPI specifications you want to compare.
22You will get something like this in your pull requests:
24
26For more detail please see our [integration guide](docs/Integration_guide.md).
32You are developing a very important server with a REST API. You have clients who use your API that you do not control. Say, you are also developing a mobile app that uses your API and you can't force someone to update to the latest version. (Or you prefer not to for UX reasons.)
34You have recently released version 1.0 and things are going great: user are downloading your app, servers are processing requests.
36You describe your API in a file `api-1.0.0.yaml`:
42 title: Swagger Petstore
46 - url: https://example.com
67 $ref: "#/components/schemas/Pets"
73 $ref: "#/components/schemas/Pet"
94 $ref: "#/components/schemas/Pet"
97### Evolving your product
99Enthused over your initial success you hurry to release a new and improved version of your API and mobile app.
101After a round of very intense programming you take a look at your new `api-1.1.0.yaml`:
107 title: Swagger Petstore
111 - url: https://example.com
132 $ref: "#/components/schemas/Pets"
138 $ref: "#/components/schemas/Pet"
161 $ref: "#/components/schemas/Pet"
164Looking at the very large and complex API description, you grow more and more concerned that your old mobile app might stop working when you update the server. But the spec is too large and too complex to reasonably assess this manually.
166### Assessing compatibility automatically
168Luckily, you have access to compaREST which can programmatically analyze your APIs and determine what, if anything, breaks compatibility and what doesn't.
170You can call it, passing the API your client will be aware of, and the API your server will serve like so:
173docker run --rm -v $(pwd):/data:rw typeable/comparest --client /data/api-1.0.0.yaml --server /data/api-1.1.0.yaml --output /data/report.md
176Running this command will output a file `report.md`, containing the compatibility report between the two APIs:
180> | [❌ Breaking changes](#breaking-changes) | [⚠️ Non-breaking changes](#non-breaking-changes) |
181> |------------------------------------------|--------------------------------------------------|
184> # <span id="breaking-changes"></span>❌ Breaking changes
188> ### ⬅️☁️ JSON Response – 200
190> #### `$[*].name(String)`
192> 1. Maximum length of the string changed from 10 to 15.
194> 2. Minimum length of the string changed from 3 to 1.
198> ### ➡️☁️ JSON Request
202> 1. Values are now limited to the following types:
206> 2. The property was previously implicitly described by the catch-all
207> "additional properties" case. It is now explicitly defined.
209> #### `$.weight(Number)`
211> Value is now a multiple of 1.0.
213> # <span id="non-breaking-changes"></span>⚠️ Non-breaking changes
223> Upper bound changed from 20.0 inclusive to 30.0 inclusive.
225> ### ⬅️☁️ JSON Response – 200
229> 1. Values are now limited to the following types:
233> 2. The property was previously implicitly described by the catch-all
234> "additional properties" case. It is now explicitly defined.
236> #### `$[*].weight(Number)`
238> Value is now a multiple of 1.0.
242> ### ➡️☁️ JSON Request
244> #### `$.name(String)`
246> 1. Maximum length of the string changed from 10 to 15.
248> 2. Minimum length of the string changed from 3 to 1.
250You now know exactly in what situations and in what way your 1.0 version of the app will break if you deploy your 1.1 version of the server.
252### Additional formats
254You can also produce a self-contained HTML report that you can open in your browser by simply omitting the file extension of the output file:
257docker run --rm -v $(pwd):/data:rw typeable/comparest --client /data/api-1.0.0.yaml --server /data/api-1.1.0.yaml --output /data/report
262For more detail please see our [user guide](docs/User_guide.md).
265Usage: comparest (-c|--client ARG) (-s|--server ARG)
266 [--silent | --only-breaking | --all] [-o|--output ARG]
267 [--folding-block-quotes-style | --header-style]
269 A tool to check compatibility between two OpenAPI specifications.
273 Compare files old.yaml with new.yaml and output the resulting report to
276 comparest -c old.yaml -s new.yaml
278 Only output breaking changes and write a styled HTML report to file
281 comparest -c old.yaml -s new.yaml --only-breaking -o report
283 Don't output anything, only fail if there are breaking changes:
285 comparest -c old.json -s new.json --silent
287 Write full report suitable for embedding into a GitHub comment to
290 comparest -c old.json -s new.json --folding-block-quotes-style -o report.html
293 -h,--help Show this help text
294 -c,--client ARG A path to the file containing the specification that
295 will be used for the client of the API. Can be either
297 -s,--server ARG A path to the file containing the specification that
298 will be used for the server of the API. Can be either
300 --silent Silence all output. Only makes sense in combination
301 with --signal-exit-code.
302 --only-breaking Only report breaking changes in the output.
303 --all Report both incompatible and compatible changes.
304 Compatible changes will not trigger a failure exit
306 -o,--output ARG The file path where the output should be written. If
307 the option is omitted the result will be written to
310 The file extension is used to determine the type of
313 Supports many formats such as markdown, html, rtf,
314 doc, txt, rst, and many more.
316 Leave out the extension to produce a self-contained
317 HTML report with styling.
318 --folding-block-quotes-style
319 The report tree is structured using summary/detail
320 HTML elements and indented using block quotes. This
321 style renders well on GitHub.Intended for HTML output
322 format. Markdown has rendering bugs on GitHub.
323 --header-style The report tree is structured using increasing levels
325 --signal-exit-code Signal API compatibility with the exit code.
327 Exit with 0 if there are no breaking changes.
328 Exit with 1 if there are breaking changes.
329 Exit with 2 if could not determine compatibility.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list