Apiary.io - multiple responses (200) with different parameters

拜拜、爱过 提交于 2019-11-30 18:11:19

Nothing is wrong with your blueprint. I am afraid the Apiary Mock is rather simplistic and always returns the first response specified (content-negotiation permitting) as default.

See "Invoking non-default responses" at Apiary http://support.apiary.io/knowledgebase/articles/117119-handling-multiple-actions-on-a-single-resource to see how to invoke (on demand) another response.

Also note there is a proposed syntax in API Blueprint to explicitly state what values of parameters are tied to a particular response – https://github.com/apiaryio/api-blueprint/issues/58

However whether will Apiary's mock take benefit of this is unclear at the moment.

I believe there is a simple solution to do this without using headers:

Create different resources (one for each record), so each one will generate one 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"
        } 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!