I have a response body with contents like below, i...
# pact-go
a
I have a response body with contents like below, is there a way to match the values in Header using dsl.Match and just validate the type of the fields inside Body part using dsl.Like in pact.AddInteraction WillRespondWith section?
Copy code
[
    {
        "Body": {
             "environments": [
                               {
                                    "createdDate": "2020-05-20",
                                    "id": "abc",
                                    "name": "abc",
                                    "state": "YES",
                                    "tags": [],
                                    "status": false
                                }
                            ],
               "nPageKey": "aabbgggcc==",
               "pageSize": 1,
               "totalCount": 1
              },
        "Header": {
               "ResponseCode": 200,
               "Region": "xyz"
         }
     }
 ]
m
You want to match exact values in the header, but types in the body?
I think so, you just need to not put matchers (via struct tags) on the things that should be exact matched
a
Thank you for the reply! Do you mean if I don't put pact:"example=value" on Struct, it will work using dsl.Match? sorry I am new to pact, so confirming.
m
Yes it should just mean "match exact value"
If that doesn't work, you might need to use the standard matchers
a
thank you so much!
👍 1