Hey folks :wave: if I’m loading existing JSON into...
# pact-jvm
j
Hey folks 👋 if I’m loading existing JSON into a
MessagePactBuilder
or
ConsumerPactBuilder
is there any way to apply matching rules to them afterwards so this basic type match is added to the contract?
Copy code
"matchingRules": {
    "$.body": {
        "match": "type"
    }
},
Some sample code for context:
Copy code
JSONObject jsonObject = loadJsonFromFile( stubFile );

ConsumerPactBuilder.consumer( "consumer" )
    .hasPactWith( "provider" )
    .uponReceiving( "aRequest" )
    .path( "/" )
    .body( "{}" )
    .willRespondWith()
    .body( jsonObject )
    .toPact();

new MessagePactBuilder()
    .expectsToReceive( "aMessage" )
    .withContent( jsonObject )
    .toPact();
u
There is no DSL support for that, but you could add them yourself to the generated interactions.
j
Thanks for clarifying @uglyog - do you mean just edit the JSON file after its generated?