Request body matching in WireMock (not JSON/XML)
<p>I am trying to create a API mock with standalone wiremock. The response body depends upon an attribute in the request body.</p>

<p>With JSON, I was able to do. Here is sample mapping:</p>

<pre><code>{
   "request":{
      "method":"POST",
      "bodyPatterns":[
         {
            "matchesJsonPath":"$.somekey.subkey[?(@.attribute == 'VALUE_123')]"
         }
      ]
   },
   "response":{
      "status":200,
      "bodyFileName":"res.dat",
      "headers":{
         "Content-Type":"application/x-proto;charset=UTF-8"
      }
   }
}
</code></pre>

<p>However my main requirement is to deal with google protobuf and I am trying to use text format in lieu of it that mockers will use to mock the API for response. So, the request file is in text format, and does not have any JSON validations like double quotes, or comma at end of each line, etc.</p>

<p>I found that using JSON path, wiremock is unable to match the request body due to its improper format.
For example, a request like this:</p>

<pre><code>{
animal {
type {
key1: "value"
key2: value2
}
}
}
</code></pre>

<p>instead of</p>

<pre><code>{  
   "animal":{  
      "type":{  
         "key1":"value",
         "key2":"value2"
      }
   }
}
</code></pre>

<p>Lets say <code>key1</code> = <code>value1</code> should match and <code>response1.json</code> should be returned, or when <code>key1</code> = <code>someOtherValue</code>, then <code>response2.json</code> should be returned.
And yes, key is part of type, and type is part of animal. How can I achieve this request body matching?</p>