我正在使用Wiremock来删除移动客户端发出的一些API调用.
努力从请求中获取模板文件名.
任何人都可以确认这是否应该与Wiremock独立使用?
"response": { "status": 200, "bodyFileName": "Account-{{jsonPath request.body '$.user.identity'}}.json”}
Run Code Online (Sandbox Code Playgroud)
我有静态文件要返回正常,似乎bodyFileName不喜欢模板.
例:
我用以下Json配置wm:
{
"request": {
"method" : "GET",
"url": "/users/D8428899330"
},
"response": {
"status": 200,
"bodyFileName": "user-{{request.path.[1]}}.json"
}
}
Run Code Online (Sandbox Code Playgroud)
然后当我尝试url时,http:// localhost:9696/users/D8428899330我收到以下错误,
HTTP错误:500访问/ users/D8428899330时出现问题.原因:
了java.lang.RuntimeException:java.io.FileNotFoundException:/Users/iainframe/Documents/__files/user-{{request.path.[1]}}.json(没有这样的文件或目录)
应该表明文件user-D8428899330.json resides位于正确的位置,因为我已对其进行了硬编码并将其恢复正常.启动WireMock的命令是:
java -jar ~/Documents/wm.jar --port 9696 --global-response-templating --verbose --root-dir /Users/iainframe/Documents/
Run Code Online (Sandbox Code Playgroud) wiremock ×1