Warm tip: This article is reproduced from serverfault.com, please click

Dynamic wiremock to capture filter parameter and return in response

发布于 2020-12-18 14:13:24

I am trying to create dynamic mocks using WireMock. I have a situation where if I specify URL like

for this kind of request

/myManagement/v1/source?filters=myParty.id%3D%3D539%26myParty.role%3D%individual

what can I used so response will filter out the id and role and put in the response.

             {
                "id": "539",
                "href": "http://mypartyid/539,
                "name": "Employee",
                "role": "Customer",
                "validFor": {
                    "startDateTime": "2020-10-27T10:52:30.008Z"
                }
            }

I am using standalone wiremock jar 2.27.2 to create wiremock-server.

Questioner
sagar verma
Viewed
0
agoff 2020-12-19 02:23:15

Since your query parameters are not separated but are sent as a single parameter, you'll need to create a custom transformer to modify the response.

Read more about transforming responses here.