Apidoc: How to return a array?

Created on 25 Feb 2015  路  5Comments  路  Source: apidoc/apidoc

Hi,
If my response is a array like
[
{"id" : 1, "name" : "John"},
{"id" : 2, "name" : "Mary"},
]
How could I set in @apiSuccess?
I had try Object[] but did not know how to set the field name.
Thanks.

Most helpful comment

I'm using a dash (-) for the placeholder:

@apiSuccess {Object[]}  -       List of users, "response" is only a placeholder.
@apiSuccess {Number}    -.id    The ID.
@apiSuccess {String}    -.name  The Name.

All 5 comments

Give it a name, see https://github.com/apidoc/apidoc/issues/23#issuecomment-30653830

@apiSuccess {Object[]} response      List of users, "response" is only a placeholder.
@apiSuccess {Number}   response.id   The ID.
@apiSuccess {String}   response.name The Name.

We have currently not an empty identifier, a '*' is not a good option, people will use it in the wrong way.

"'response' is a placeholder" is really not sexy.
"root" might be a nice placeholder. Maybe with some extra special char...
Anyway, tons of API endpoints reply with an array right?

Yep I'm in this case too.. I generate now the docs for an existing API, so I can't modify it at all (by adding an intermediate property).... and well I'm not sure it's a good idea to adapt an API for a specific doc tool.

So I can't use apidoc :(

I'm using a dash (-) for the placeholder:

@apiSuccess {Object[]}  -       List of users, "response" is only a placeholder.
@apiSuccess {Number}    -.id    The ID.
@apiSuccess {String}    -.name  The Name.

@vinniecent To me your solution looks the nicest, thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tyranron picture tyranron  路  3Comments

brandonhamilton picture brandonhamilton  路  4Comments

gemal picture gemal  路  4Comments

ameliariely picture ameliariely  路  7Comments

yunlucolin picture yunlucolin  路  6Comments