This seems to be a common issue with Pact and I cannot find a solution and it seems unresolvable, but I just thought I'd check on StackOverflow.
My API response returns an array of objects each of which has a children attribute (a list of child objects in my case veryone the same shape) .
{
"type": "parent",
children: [] // or [{"name": "Buzz"}..... ]
}
If the parent object doesn't have any children the list is empty else it has child objects. So the response contains both types of object.
Pact matcher EachLike has a minimum of 1, meaning, (as I understand it), the list of objects must all have either an attribute for a empty list or list of length > 0. So I cannot use that matcher to resolve this.
I cannot write two contracts for this as the API response contains parent objects with and without children. Both contracts would be wrong.
Can I accomodate either parent object has empty children list or populated children list ?