我试图通过不同的参数获得不同的响应,但有些东西不起作用。
这是我的 API:
## Question [/questions/{question_id}]
A Question object has the following attributes:
+ Parameters
+ question_id: `1` (number, required) - ID of the Question in form of an integer
### View a Questions Detail [GET]
+ Request
+ Header
X-Custom-Header : 1
+ Response 200 (application/json)
{
"id": "1",
"name": "Marco"
}
+ Request
+ Header
X-Custom-Header : 2
+ Response 200 (application/json)
{
"id: "2",
"name": "Lucas"
}
但是当调用 /questions/1 或 /questions/2 时,响应总是相同的:
{
"id": "1",
"name": "Marco"
}
怎么了?
谢谢
你的蓝图没有任何问题。恐怕 Apiary Mock 相当简单,并且总是返回指定的第一个响应(内容协商允许)作为默认值。
请参阅 Apiary 中的“调用非默认响应”http://support.apiary.io/knowledgebase/articles/117119-handling-multiple-actions-on-a-single-resource查看如何(按需)调用另一个响应。
另请注意,API 蓝图中有一个建议的语法,用于明确说明哪些参数值与特定响应相关联 –https://github.com/apiaryio/api-blueprint/issues/58
然而,Apiary 的模拟是否会利用这一点目前还不清楚。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)