4

我在 Sails.js 应用程序中使用apiDoc文档。而且,上周我看到有人在一个名为api_definitions.js的文件中定义了多个控制器使用的响应

例子

/*
* @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"
* }
*/

并且,在每个控制器中,使用正常的Use Parameter @apiUse UserSuccessExample引用它。但是当我尝试它时,我在控制台中收到一个错误,说它没有定义:

错误

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' }
4

0 回答 0