pact-jvm
pact-jvm copied to clipboard
Provide a set of examples for JsonArrayLike
Hello,
I have read some best practices on Pact, saying that it is more efficient to define a contract using matchers (pattern, type ...) rather than static data. Hopefully with dsl methods like stringPattern or StringType we can provide an example.
But when talking about list of object, it is more painfull. For instance : .minArrayLike(2, array -> { array.stringType("foo", "bar"); array.numberType("id", 1); }) will generate 2 example objects with the same body. It is not convenient if i use the pact file with pact-stub-server to launch a mock of my provider where examples should reflect specific usecases.
is it possible to have something like this :
.minArrayLike(2, (array, example) -> { array.stringType("foo"); array.numberType("id"); example.add("bar", 1); example.add("otherBar", 2); })
a kind of bi-function, where you could specify all examples you need for a list in order to use pact file to start a mock ?
I hope you could understand my request, as my english is not really good !
Thank you
ps : note that the syntax of my example code is maybe not correct, it's just to explain my request