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.
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! :)
Most helpful comment
I'm using a dash (-) for the placeholder: