Thibaut Bodart
01/25/2023, 11:06 PM4.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.
"08f7a210-95db-4827-bcc8-d2025ba506cf"
I am using the following code to define the interaction:
...
.willRespondWith()
.status(201)
.headers(headers())
.body(PactDslJsonRootValue.uuid(JOB_ID)));
With 4.3.17
, using a Pact v3 contract, the generated contract looks like:
"response": {
"body": "\"08f7a210-95db-4827-bcc8-d2025ba506cf\"",
.....
}
With 4.4.4
, using a Pact v4 contract, it looks like:
"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.
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?
"response": {
"body": {
"content": "\"08f7a210-95db-4827-bcc8-d2025ba506cf\"",
"contentType": "application/json",
"encoded": false
},
Thanks in advance!