Testing response compliance using JSON schemas

Do you have REST responses that you'd like to validate against a JSON schema? This recipe shows a simple way to do this using a Groovy TestStep.

Getting ready

First, we're going to need a simple test project with a mock that produces some sample JSON responses for us to validate. A ready-made project invoice-rest-json-schema-soapui-project.xml has been provided to do this in the chapter 4 samples. It contains a simple REST project with one resource GET /invoice/{id}, a mock with two sample responses, and a test case with REST TestRequest and Groovy TestSteps. The invoice document is the usual example; that is:

{"invoice": {
   "id": 12345,
   "companyName": "Test Company",
   "amount": 100
}}

We'll also need a ...

Get SoapUI Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.