Hello. I am migrating from `4.3.17` to `4.4.4` sin...
# pact-jvm
t
Hello. I am migrating from
4.3.17
to
4.4.4
since I would like to use the V4 Pact specifications. My response is in JSON format and only contains a UUID. See below a valid JSON response.
Copy code
"08f7a210-95db-4827-bcc8-d2025ba506cf"
I am using the following code to define the interaction:
Copy code
...
.willRespondWith()
.status(201)
.headers(headers())
.body(PactDslJsonRootValue.uuid(JOB_ID)));
With
4.3.17
, using a Pact v3 contract, the generated contract looks like:
Copy code
"response": {
        "body": "\"08f7a210-95db-4827-bcc8-d2025ba506cf\"",
        .....
}
With
4.4.4
, using a Pact v4 contract, it looks like:
Copy code
"response": {
        "body": {
          "content": "08f7a210-95db-4827-bcc8-d2025ba506cf",
          "contentType": "application/json",
          "encoded": false
        },
.....
}
The content value is not a valid JSON value in the case of
4.4.4
. For this reason, the contract cannot be verified by the provider (also using pact-jvm
4.4.4
). See the exception below. This is expected since
"08f7a210-95db-4827-bcc8-d2025ba506cf"
is not a valid JSON document whereas
"\"08f7a210-95db-4827-bcc8-d2025ba506cf\""
is.
Copy code
1.1) Invalid JSON (1:5), found unexpected character '7'
Am I doing something wrong? If I modify the contract manually as illustrated below, the provider can successfully verify it. Is there a way to generate the response below using the Pact DSL?
Copy code
"response": {
  "body": {
    "content": "\"08f7a210-95db-4827-bcc8-d2025ba506cf\"",
    "contentType": "application/json",
    "encoded": false
  },
Thanks in advance!