wilson Liu
wilson Liu

Reputation: 579

How to set array response in 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.

Upvotes: 6

Views: 4113

Answers (1)

Utsav Dawn
Utsav Dawn

Reputation: 8246

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.
 */

Upvotes: 9

Related Questions