Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Wiremock standalone body-transformer is not working with bodyPatterns and matchesJsonPath #45

Open
rajputvijay32 opened this issue Jan 28, 2020 · 0 comments

Comments

@rajputvijay32
Copy link

I am using wiremock to stubbing the requests. I have created a json file to stub a request:

{
"request": {
"method": "POST",
"urlPath": "/nested/transform",
"bodyPatterns": [
{
"matchesJsonPath": "$.names.[0].['first']"
},
{
"matchesJsonPath": "$.names.[0].['last']"
}
]
},
"response": {
"status": 200,
"body": "{"firstName": "$(names[0].first)", "lastName": "$(names[1].last)"}",
"headers": {
"Content-Type": "application/json"
},
"transformers": ["body-transformer"]
}
}

My request and response are as below:

{
"names": [
{
"first": "Vijay",
"last": "Rajput"
}
]
}

Receiving response is -
{
"firstName": "[{first=Vijay, last=Rajput}]",
"lastName": "[{first=Vijay, last=Rajput}]"
}

Expected response is -
{
"firstName": "Vijay",
"lastName": "Rajput"
}

Is it possible to fetch?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant