Create RequestResponsePact via json file
complete
Komal Sharma
We tried to read pact from the json file directly in our use case but in order to make it work we had to modify existing library because there was no method in the existing library to match body by type instead of value when we were reading the contract from the json file directly. Here are the screenshot of code snippet where we have modified the exiting library to add matcher rule for the body.
It would be good if we can add a method to add matcher rule for the body as a feature.
Yousaf Nabi
complete
Support is provided by a community plugin
https://github.com/sngular/pact-annotation-processor
which allows users to easy generate DslPart objects for the body definitions based on annotations included in your model classes.
Matt Fellows
I think what you're asking for is to be able to provide a JSON blob into the DSL and match the entire JSON based on type?
Yousaf Nabi
Matt Fellows: That is what I read from the post, isn't that possible with the SomethingLike/Like Matcher wrapped round the json body?
Matt Fellows
Yousaf Nabi: In the scripted languages it's common, but I don't think JVM supports it as of now
Komal Sharma
Matt Fellows: Yes, we achieved it but had to do some modification to match the body by type. If we send this pact as is without adding matcher rule then it will try to match the value also. Here are the screenshots for your reference of the generated pact where you can see the applied matching rule on the body which is by type and this is the result of the modification we have done in the existing library by implementing matchingRule interface