6

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.

wilson Liu
  • 579
  • 2
  • 8
  • 18

1 Answers1

9

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.
 */
Utsav Dawn
  • 7,896
  • 2
  • 29
  • 44