Howdy folks. I'm having issues specifying rather s...
# pact-jvm
p
Howdy folks. I'm having issues specifying rather simple pact for one of our consumers. The contract is defining a particular payload schema on POST call, where
parameters
field is a Map<String, String> of undefined size and fields.
Copy code
{
  "id": "string"
  "parameters": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  }
}
I'm banging my head how to tackle it:
Copy code
@Pact(consumer = CONSUMER)
RequestResponsePact pact(PactDslWithProvider builder) {
    return builder
            .uponReceiving("Post message")
            .path("/api/messages")
            .method("POST")
            .body(newJsonBody(body -> {
                body.stringType("id", "example_id");
//                    body.object("parameters", values -> values.eachLike())
            }).build())
            .matchHeader("Content-Type", "application/json.*", "application/json")
            .willRespondWith()
            .status(200)
            .toPact();
}
I don't know how to specify the
parameters
pact part to accept the Map<String, String>. Basically for JSON it's an object with a number of string fields, but don't know how to define pact for it
r
Use
eachLike("parameters", obj -> ....)