This is my patch request mapping in data.yaml
request:
url: ^/api/test
method: PATCH
headers:
Content-Type: application/json
response:
headers:
Content-Type: application/json
status: 200
file: response/test-1.json
api path api/test is a PATCH request which accepts a single request parameter in it's body {testVar: "1111"}
what I need to implement is when request param is {testVar: "1111"} -> call response/test-1.json when request param is {testVar: "2222"} -> call response/test-2.json
how can this be implemented?
I tried the query params, request params etc. but with no luck
Have a read at:
The idea here is:
In your
POST
/PATCH
request payload, you can specify one of the params to be a regex, e.g.:{"testVar": "(.*)"}
. The regex's tokens upon matching (i.e.: the value of(.*)
), can be used as a replacement token for yourresponse
configuration. In other words, you should be able to load the respective JSON file as needed.But, to make this a little easier for you, try the following YAML config:
Let me know if the above works for you. For reference, I have tested the above config in the following PR: https://github.com/azagniotov/stubby4j/pull/280