-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with JSON response body containing a string as root value #1658
Comments
/jira ticket |
👋 Thanks, Jira [PACT-688] ticket created. |
The content is correctly formed, as the Pact file is JSON and the contents is JSON, so the body contents is written directly as is. It must be an error with the provider verification. Are able to provide the debug logs from the provider verification? I am going to update it to write the Pact file as "response": {
"body": {
"content": "08f7a210-95db-4827-bcc8-d2025ba506cf",
"contentType": "application/json",
"encoded": "json" //<---
}, to make it explicit that it has been encoded in JSON form. |
Actually, I think I have replicated the issue. It is when the Pact file is loaded. |
Just a note, after reviewing the V4 spec, the correct forms are: "response": {
"body": {
"content": "08f7a210-95db-4827-bcc8-d2025ba506cf",
"contentType": "application/json",
"encoded": false
}, or "response": {
"body": {
"content": "\"08f7a210-95db-4827-bcc8-d2025ba506cf\"",
"contentType": "application/json",
"encoded": "JSON"
}, Currently, there is no way with the DSL to get it to write the latter form. |
Thanks a lot for the quick feedback and action! |
I am migrating from
4.3.17
to4.4.4
and upgrading my contracts to use the V4 Pact specifications (from V3).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:
With
4.3.17
, using a Pact v3 contract, the generated contract looks like:With
4.4.4
, using a Pact v4 contract, it looks like:The value of the content property is not a valid JSON value in the case of
4.4.4
and the V4 spec.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 (double quotes are required since this is a string and not a numerical value).Am I doing something wrong or is that a bug? 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?
Thanks in advance!
The text was updated successfully, but these errors were encountered: