我试图得到不同的反应,通过不同的参数,但有些东西不起作用。
这是我的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"
}但是,当调用/问询/1或/问询/2时,响应总是相同的:
{
"id": "1",
"name": "Marco"
}怎么啦?
谢谢
发布于 2015-06-18 11:54:01
你的蓝图没什么问题。恐怕Apiary相当简单,总是返回指定的第一个响应(内容协商允许)作为默认。
参见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的模拟是否会从中受益。
发布于 2015-06-19 10:35:27
我相信有一个简单的解决方案可以做到这一点而不使用标题:
创建不同的资源(每个记录一个),因此每个资源都将生成一个URL。
## Note20 [/notes/20]
### Get notes20 [GET]
+ Response 200 (application/json)
{
"id" : 20,
"name" : "note xxxx"
}
## Note21 [/notes/21]
### Get notes21 [GET]
+ Response 200 (application/json)
{
"id" : 21,
"name" : "note yyyyy"
} https://stackoverflow.com/questions/30911765
复制相似问题