4

I am using apiDoc for documentation in Sails.js app. And, last week I saw someone define responses being used by multiple controllers in a file named api_definitions.js

Example

/*
* @apiDefine UserSuccessExample
* @apiSuccessExample Success-Response:
*     HTTP/1.1 201 OK
* {
*   "message": "User Created successfully",
*   "user" : {
*       "displayname": "somedisplayname",
*       "lastname": "ALastName",
*       "firstname": "AFirstName",
*       "email": "sososo@soos.so",
*       "phonenumber": "0839293288"
*   },
*   "token" : "ey.jkernekrerkerkeekwewekwbejwbewbebewbwkebebbwbeibwubfebfebwiee"
* }
*/

And, in each of the controllers, referenced it using the normal Use Parameter @apiUse UserSuccessExample. But when I tried it, I was getting an error in my console saying, it wasn't defined:

Error

error: Referenced groupname does not exist / it is not defined with @apiDefine.
{ File: 'api/controllers/UserController.js',
  Block: 2,
  Element: '@apiUse',
  Groupname: 'UserSuccessExample',
  Definition: '@apiUse group',
  Example: '@apiDefine MyValidGroup Some title\n@apiUse MyValidGroup' }
  • Maybe a little bit late but still... I had to add `/**` instead of `/*` at opening comment tag. Hope it helps. – Jure Jager Nov 07 '17 at 09:51

0 Answers0