我正在尝试使用WireMock创建动态mock。我的URL是这样的:
http://localhost:8080/manage/classids/query1=ns1/query2=id1
那么我想要输出为
{
"yourId":"id1"
}
我试着喜欢这种方式
{
"name": "Req_GET",
"request": {
"urlPathPattern": "/manage/classids/query1=([a-zA-Z0-9]*)/query2=([a-zA-Z0-9]*)",
"method": "GET"
},
"response": {
"status": 200,
"jsonBody": {
"yourId": "{{request.path.[3]}}"
},
"transformers": [
"response-template"
],
"headers": {
"Content-Type": "application/json"
}
}
}
但我不能在"="在"/">
{
"yourId":"query2=id1"
}
您可以使用WireMock的请求模型直接引用查询参数
...
"yourId": "{{request.query.query1}}"
...