我在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"
* }
*/
并且,在每个控制器中,使用正常使用参数 @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' }