title: Spring Cloud Contract Verifier - Body matching
body: <p>I'm using Spring Cloud Contract Verifier</p>
  
  <p>org.springframework.cloud:spring-cloud-starter-contract-verifier:jar:2.0.0.M8
  org.springframework.cloud:spring-cloud-contract-maven-plugin:1.2.4.RELEASE</p>
  
  <p>And I have the following contract:</p>
  
  <pre><code>request:
    method: GET
    url: /cars/list
  response:
    status: 200
    headers:
      Content-Type: application/json;charset=UTF-8
    body:
      cars:
        [
          {
            "make": "Ford",
            "model": "Fiesta",
            "year": 2016,
            "price": 16500.50
          },
          {
            "make": "BMW",
            "model": "X1",
            "year": 2014,
            "price": 22000.00
          },
          {
            "make": "NISSAN",
            "model": "Juke",
            "year": 2017,
            "price": 19300.00
          }
        ]
  </code></pre>
  
  <p>Which is then converted in following java code:</p>
  
  <pre><code>DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
  assertThatJson(parsedJson).array("['cars']").contains("['model']").isEqualTo("Juke");
  assertThatJson(parsedJson).array("['cars']").contains("['make']").isEqualTo("Ford");
  assertThatJson(parsedJson).array("['cars']").contains("['year']").isEqualTo(2014);
  assertThatJson(parsedJson).array("['cars']").contains("['year']").isEqualTo(2016);
  assertThatJson(parsedJson).array("['cars']").contains("['model']").isEqualTo("Fiesta");
  assertThatJson(parsedJson).array("['cars']").contains("['make']").isEqualTo("BMW");
  assertThatJson(parsedJson).array("['cars']").contains("['year']").isEqualTo(2017);
  assertThatJson(parsedJson).array("['cars']").contains("['make']").isEqualTo("NISSAN");
  assertThatJson(parsedJson).array("['cars']").contains("['price']").isEqualTo(16500.5);
  assertThatJson(parsedJson).array("['cars']").contains("['model']").isEqualTo("X1");
  assertThatJson(parsedJson).array("['cars']").contains("['price']").isEqualTo(22000.0);
  assertThatJson(parsedJson).array("['cars']").contains("['price']").isEqualTo(19300.0);
  </code></pre>
  
  <p>I have a few issues with this test:</p>
  
  <p>1) It does not take order into account, meaning the following body would still be considered valid:</p>
  
  <pre><code>{
    "cars": [
      {
        "make": "NISSAN",
        "model": "Juke",
        "year": 2017,
        "price": 19300.00
      },
      {
        "make": "BMW",
        "model": "X1",
        "year": 2014,
        "price": 22000.00
      },
      {
        "make": "Ford",
        "model": "Fiesta",
        "year": 2016,
        "price": 16500.50
      }
    ]
  }
  </code></pre>
  
  <p>2) It just verifies that certain property is present anywhere in the response, meaning the following body would still be considered valid:</p>
  
  <pre><code>{
    "cars": [
      {
        "make": "Ford",
        "model": "Juke",
        "year": 2016,
        "price": 19300.00
      },
      {
        "make": "BMW",
        "model": "X1",
        "year": 2017,
        "price": 22000.00
      },
      {
        "make": "NISSAN",
        "model": "Fiesta",
        "year": 2014,
        "price": 16500.50
      }
    ]
  }
  </code></pre>
  
  <p>3) It ignores any extra values present in the response, meaning the following body would still be considered valid:</p>
  
  <pre><code>{
    "cars": [
      {
        "make": "Ford",
        "model": "Fiesta",
        "year": 2017,
        "price": 22000.00,
        "state": "good"
      },
      {
        "make": "NISSAN",
        "model": "Juke",
        "year": 2016,
        "price": 19300.00,
        "state": "ok"
      },
      {
        "make": "BMW",
        "model": "X1",
        "year": 2014,
        "price": 16500.50
      },
      {
        "make": "Volkswagen",
        "model": "Golf",
        "year": 2018,
        "price": 12500.00,
        "state": "new"
      }
    ]
  }
  </code></pre>
  
  <p>I would like the generated test to be more strict and fail on any differences outlined in cases above.</p>
  
  <p>Can it be achieved with Spring Cloud Contract Verifier?</p>