Reducing Integration Hassles With JSON Schema Contracts

I recently worked on a project where the 'contract' between service consumers and providers consisted primarily of annotated mock-ups of the JSON responses one would obtain from each of a given service's end-points. A much better way of expressing the contract for a service is to use a standard schema format. If you're stuck with XML, use XML schema. If you are using JSON, there are tools and libraries (presented below) that will help you use JSON schema to express a service's contract.

This article will assume that you have gone through the available JSON schema documentation and have a basic idea of how to use it. It assumes that you are developing on a JVM-based platform, and most of the recipes will be helpful for Java developers (although our example of dynamic schema validation is presented using a bit of Scala.)