3[](https://hackage.haskell.org/package/comparest)
4[](http://stackage.org/lts/package/comparest)
5[](http://stackage.org/nightly/package/comparest)
6[](LICENSE)
8Compatibility checker for OpenAPI
13You 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.)
15You have recently released version 1.0 and things are going great: user are downloading your app, servers are processing requests.
17You describe your API in a file `api-1.0.0.yaml`:
23 title: Swagger Petstore
27 - url: https://example.com
48 $ref: "#/components/schemas/Pets"
54 $ref: "#/components/schemas/Pet"
75 $ref: "#/components/schemas/Pet"
78## Evolving your product
80Enthused over your initial success you hurry to release a new and improved version of your API and mobile app.
82After a round of very intense programming you take a look at your new `api-1.1.0.yaml`:
88 title: Swagger Petstore
92 - url: https://example.com
113 $ref: "#/components/schemas/Pets"
119 $ref: "#/components/schemas/Pet"
142 $ref: "#/components/schemas/Pet"
145Looking 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.
147## Assessing compatibility automatically
149Luckily, you have access to compaREST which can programmatically analyze your APIs and determine what, if anything, breaks compatibility and what doesn't.
151You can call it, passing the API your client will be aware of, and the API your server will serve like so:
154docker 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
157Running this command will output a file `report.md`, containing the compatibility report between the two APIs:
161> | [⚠️ Breaking changes](#breaking-changes) | [🙆 Non-breaking changes](#non-breaking-changes) | 🤷 Unsupported feature changes |
162> |------------------------------------------|-------------------------------------------------|-------------------------------|
165> # <span id="breaking-changes"></span>⚠️ Breaking changes
169> ### 📱⬅️ JSON Response – 200
171> #### `$[*].name(String)`
173> 1. Maximum length of the string changed from 10 to 15.
175> 2. Minimum length of the string changed from 3 to 1.
179> ### 📱➡️ JSON Request
183> 1. Values are now limited to the following types:
187> 2. The property was previously implicitly described by the catch-all
188> "additional properties" case. It is now explicitly defined.
190> #### `$.weight(Number)`
192> Value is now a multiple of 1.0.
194> # <span id="non-breaking-changes"></span>🙆 Non-breaking changes
204> Upper bound changed from 20.0 inclusive to 30.0 inclusive.
206> ### 📱⬅️ JSON Response – 200
210> 1. Values are now limited to the following types:
214> 2. The property was previously implicitly described by the catch-all
215> "additional properties" case. It is now explicitly defined.
217> #### `$[*].weight(Number)`
219> Value is now a multiple of 1.0.
223> ### 📱➡️ JSON Request
225> #### `$.name(String)`
227> 1. Maximum length of the string changed from 10 to 15.
229> 2. Minimum length of the string changed from 3 to 1.
231You 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.
235You 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:
238docker 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
244Usage: comparest (-c|--client ARG) (-s|--server ARG)
245 [--silent | --only-breaking | --all] [-o|--output ARG]
246 [--folding-block-quotes-style | --header-style]
248 A tool to check compatibility between two OpenAPI specifications.
252 Compare files old.yaml with new.yaml and output the resulting report to
255 comparest -c old.yaml -s new.yaml
257 Only output breaking changes and write a styled HTML report to file
260 comparest -c old.yaml -s new.yaml --only-breaking -o report
262 Don't output anything, only fail if there are breaking changes:
264 comparest -c old.json -s new.json --silent
266 Write full report suitable for embedding into a GitHub comment to
269 comparest -c old.json -s new.json --folding-block-quotes-style -o report.html
272 -h,--help Show this help text
273 -c,--client ARG A path to the file containing the specification that
274 will be used for the client of the API. Can be either
276 -s,--server ARG A path to the file containing the specification that
277 will be used for the server of the API. Can be either
279 --silent Silence all output. Only makes sense in combination
280 with --signal-exit-code.
281 --only-breaking Only report breaking changes in the output.
282 --all Report both incompatible and compatible changes.
283 Compatible changes will not trigger a failure exit
285 -o,--output ARG The file path where the output should be written. If
286 the option is omitted the result will be written to
289 The file extension is used to determine the type of
292 Supports many formats such as markdown, html, rtf,
293 doc, txt, rst, and many more.
295 Leave out the extension to produce a self-contained
296 HTML report with styling.
297 --folding-block-quotes-style
298 The report tree is structured using summary/detail
299 HTML elements and indented using block quotes. This
300 style renders well on GitHub.Intended for HTML output
301 format. Markdown has rendering bugs on GitHub.
302 --header-style The report tree is structured using increasing levels
304 --signal-exit-code Signal API compatibility with the exit code.
306 Exit with 0 if there are no breaking changes.
307 Exit with 1 if there are breaking changes.
308 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