Reputation: 5565
I was trying to create an API mock using apiary.io. A section of my current API blueprint looks like follows.
+ Request (application/json)
{
"key": "secret",
}
+ Response 200 (application/json)
{
"decision_type" : 1,
}
+ Response 202 (application/json)
{
"decision_type" : 2,
}
+ Response 203 (application/json)
{
"decision_type" : 3,
}
According to the API documentation provided to me, the ideal case should be such that the response status returned in all the three cases should be 200
. But since apiary uses status codes to differentiate between the responses, I am forced to use 202
and 203
status codes. Is there any way by which I could avoid this?
I thought of a functionality by which it would give different responses based on different parameters. But it seems like this functionality is still being implemented (Apiary.io - multiple responses (200) with different parameters).
Is there a way to denote the blueprint like the following?
+ Response 200 (application/json) type=1
{
"decision_type" : 1,
}
+ Response 200 (application/json) type=2
{
"decision_type" : 2,
}
+ Response 200 (application/json) type=3
{
"decision_type" : 3,
}
And this type
can be accessed as a header during REST
calls.
I will be forced to turn down apiary and move to other applications to generate a mock which would mean a great deal of work as my API is really BIG.
Upvotes: 2
Views: 342
Reputation: 854
API mock will always give your the first response in your document. If you just want to use it for mock you try something thing like this:
## Get Decision type 1 [/?type=1] ### decision type [GET] + Response 200 (application/json) { "decision_type" : 1, } ## Get Decision type 2 [/?type=2] ### decision type [GET] + Response 200 (application/json) { "decision_type" : 2, } ## Get Decision type 3 [/?type=3] ### decision type [GET] + Response 200 (application/json) { "decision_type" : 3, }
Upvotes: 1