问题描述
我正在尝试创建模拟api服务以进行测试.我们已经在另一个团队上使用了Apiary,所以我从那里开始.
I'm attempting to create mock api services for testing purposes. We are already using Apiary on another team so I'm starting there.
到目前为止,我已经注意到,如果要进行两个单独的调用,则需要模拟两个请求.例如,要获取ID为1和2的笔记,需要明确写出如下响应:
So far, I've noticed that if I want to have two separate calls requires mocking out of both requests. For example to get the notes with ids 1 and 2 requires explicitly writing out responses like:
/notes/1/notes/2
/notes/1/notes/2
有办法避免这种情况吗?诚然,我仍在努力创建蓝图.
Is there a way to avoid this? Admittedly I'm still ramping up on creating blueprints.
推荐答案
看看私人e9e59-pingdomcheck.apiary-mock.com/v1/gists/1 .这里的数字1
是{id}
.当然,您只会得到一般定义的响应(例如,如果我使用id 42).
Have a look at private-e9e59-pingdomcheck.apiary-mock.com/v1/gists/1. The number 1
is {id}
here. You of course get only the general defined response (like if I used id 42).
MSON 中现在还有更多事情要做.发布后,可以对请求中的不同参数进行不同的答复.
There are more things being done right now in MSON. Once it's released, different replies for different parameters in request will be possible.
这篇关于使用Apiary创建模拟服务API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!