Hi, I have a question regarding the lambda DSL. Th...
# pact-jvm
s
Hi, I have a question regarding the lambda DSL. There is a particular JSON structure which I’m struggling to match a contract for. A simplified example of which is:
Copy code
{
  "id": "3293bf46-050c-424d-b29f-4dd1de7300f7",
  "offerRankings": {
    "default": [
      "dcc513d2-ffe2-41a4-9b21-0371eb8d120c",
      "b3f360d1-d632-406d-83b5-5b27ae029099",
    ]
  }
}
In the above the offerRankings object can have arbitrary keys. Having looked through the docs found this section, Matching any key in a map Based on my understanding: •
eachKeyLike
can represent an arbitrary key to a string, number, boolean, object ect. •
eachKeyMappedToAnArrayLike
can represent an arbitrary key to an array of objects. Is there anything in the current version which supports an arbitrary key to an array of strings? (or other non object types) Currently we have this, which works:
Copy code
var body = newJsonBody(b -> {
    b.stringType("id", "c4b86559-1082-4041-a8f5-0175d3f391c9");
    b.object("rankings", rankings -> {
        rankings.array("default", array -> array.stringType("3fa85f64-5717-4562-b3fc-2c963f66afa5"));
    });
}).build();
But this requires a provider to specifically reference the default key. It feels like this is an edge case, but any feedback on the above is greatly appreciated.
u
Looks like you need a function something like
eachKeyMappedToPrimitiveArray
s
Is this something that would be considered for adding to the library? As above we have a work around, but might be useful for others in future too. Is there a process for proposal of this?
u
The best thing to due is raise a GitHub issue for this