Closed surpher closed 1 year ago
What is happening here, because the Pact file is JSON and the content is JSON, it renders the body as a string value. When the Pact file is used, it knows the content type is JSON, so it creates a JSON String body (i.e. adds the quotes back). It will do the same thing with an empty object {}
. It will write the JSON as "body": {}
and not "body": "{}"
.
Is there a reason that the body has to have the quotes in the Pact file? This behavior goes all the way back to the original Pact implementation.
This was reported a while back here -> https://github.com/surpher/PactSwift/issues/89#issue-1230776527
If I understand this correctly, the issue here was that the body
's content is not JSON, but a single String
value in "
which the reporter's provider was providing. libpact is removing redundant "
?
imo a bit of an edge case.
But the content type is being set, so it is JSON
Will file it under "misusing".
When preparing a Pact test using
PactSwift
(which uses pact-ffi under the hood) a test that expects only a singleString
value in the response body fails to prepare a valid response body.The response expectation In a consumer test:
Expected response written in Pact file:
Actual:
Enabling PactSwift logging shows that
PactSwift
sends the following data topact-ffi
:Initially raised at https://github.com/surpher/PactSwift/issues/89#issue-1230776527