pactflow / swagger-mock-validator

Other
13 stars 4 forks source link

feat: parse pact-v4 request/response bodies #29

Closed vwong closed 1 year ago

vwong commented 1 year ago

This PR treats the first 2 of the following bodies as the same:

{
  "contents": { "a": 1 },
  "encoded": false,
  "contentType": "application/json"
}
{
  "contents": "{\"a\":1}",
  "encoded": "JSON",
  "contentType": "application/json"
}
{
  "contents": "eyJhIjoxfQ==",
  "encoded": "base64",
  "contentType": "application/json"
}

I decided that even though, I could've base64 decoded the contents of the 3rd body to arrive at {"a":1}, and subsequently parsing it as application/json, that is too far a stretch to be realistic. In this case, we simply return the contents as {"a":1} (the string)