Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set array response in api-doc?

Tags:

api-doc

I tried to generate a API document by apidoc

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.

like image 774
wilson Liu Avatar asked Feb 25 '15 09:02

wilson Liu


1 Answers

Lets say in the above example the id and name are of a user-profile, and you have an array of user-profile objects, then the @apiSuccess will look like:

/**
 * @api {get} /users
 * @apiSuccess {Object[]} profiles       List of user profiles.
 * @apiSuccess {Number}   profiles.Id    Users id.
 * @apiSuccess {String}   profiles.Name  Users Name.
 */
like image 101
Utsav Dawn Avatar answered Oct 29 '22 15:10

Utsav Dawn