Is there a way to check nested json?
See original GitHub issueHi,
we have an API that hands out an stream of objects that look like this:
[
{
"Id": "123",
"Title": "Thing",
"Updated": "2022-01-20T11:45:09.8861475+01:00",
"Content": "{\"DocumentenID\":\"88c85db4-a02a-400f-9376-108acd146559\",\"Filetype\":\"thing\",\"DocRevisionType\":2,\"FakturierungsID\":\"cd7215cf-d998-430a-9ec1-9a8d590c2e64\",\"AggregateId\":\"123\",\"AggregateType\":\"Typ\"}",
"UserId": "userid",
"CorrelationId": "correlation",
"ContentVersion": "version2"
},
{
"Id": "123",
"Title": "Thing",
"Updated": "2022-01-20T11:45:09.9243622+01:00",
"Content": "{\"DocumentenID\":\"88c85db4-a02a-400f-9376-108acd146559\",\"ImportDatum\":\"2022-01-20T11:45:09.8859111+01:00\",\"AggregateId\":\"123\",\"AggregateType\":\"Typ\"}",
"UserId": "userid",
"CorrelationId": "correlation",
"ContentVersion": "version2"
}
]
We wanted to pact test that and obviously have issues with the nested json in the Content
property. As this is our real contract, it would be very useful to test if this contract gets broken somehow. We thought that implementing a IMatcher
would make this work, but the interface does not seem to handle some edgecase like that. I also thought of doing this in a regex but the thought of writing a regex for multiple objects just seems extremely laborious ^^ Is there a way to tell pact.net that he has to look into the string and check the json there? Or are there hooks in the library that we could use/abuse to make this possible? (I sadly guess a no)
The second issue that we will be having is, that the endpoint delivers different object in this Content
property, as you can see… In the case that we could get rid of the string property and replace it with a proper object, would we be able to pact test that? My guess is that this is also not possible, but maybe I missed something.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
We’re aiming for plugins to be supported in Q1 this year. It requires the 4.x.x branch to be merged, and the plugin functionality added. So we’re likely a few months away I’d suggest.
Will those plugins arrive with 4.0 or somewhere later down the line?
Thanks for the info and the link so far. I will give it a look.