1
This commit is contained in:
parent
0a5b9d3c8e
commit
90e0005361
@ -1,11 +1,11 @@
|
||||
/**
|
||||
* @api {GET} AA开发指南 AA开发指南
|
||||
* @apiPermission none
|
||||
* @apiGroup AA开发指南
|
||||
* @apiVersion 0.0.1
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* 所有的协议都可能携带award和property_chg,award用来显示获得的东西,propery_chg用来更新本地数据
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
* @api {GET} AA开发指南 AA开发指南
|
||||
* @apiPermission none
|
||||
* @apiGroup AA开发指南
|
||||
* @apiVersion 1.0.0
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* 所有的协议都可能携带award和property_chg,award用来显示获得的东西,propery_chg用来更新本地数据
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
@ -10,6 +10,8 @@ module.exports = class {
|
||||
'desc': '用户登录',
|
||||
'group': 'User',
|
||||
'url': 'api/v1/user/login',
|
||||
'header': [
|
||||
],
|
||||
'is_json_params': true,
|
||||
'params': [
|
||||
new common.ReqHead(),
|
||||
@ -27,9 +29,8 @@ module.exports = class {
|
||||
'desc': '用户登录',
|
||||
'group': 'User',
|
||||
'url': 'api/v1/user/info/:user_id',
|
||||
'is_json_params': true,
|
||||
'params': [
|
||||
['!rsp', [new common.RspHead()], 'ok rsp']
|
||||
['user_id', '', 'user_id', 'optional'],
|
||||
],
|
||||
'response': [
|
||||
new common.RspHead(),
|
||||
|
7
doc/admin/apidoc.json
Normal file
7
doc/admin/apidoc.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "game2006admin",
|
||||
"version": "1.0.0",
|
||||
"description": "game2006admin",
|
||||
"title": "game2006admin",
|
||||
"url": "https://game2006admin-test.kingsome.cn/"
|
||||
}
|
@ -1,3 +1,13 @@
|
||||
exports.DefaultHttpHeader = class DefaultHttpHeader {
|
||||
|
||||
constructor() {
|
||||
this.fields = [
|
||||
['access-key', 'Users unique access-key.'],
|
||||
];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
exports.ReqHead = class ReqHead {
|
||||
|
||||
constructor() {
|
||||
|
@ -46,26 +46,46 @@ class Doc
|
||||
const method = item.method ? 'GET' : item.method;
|
||||
this.data += `
|
||||
/**
|
||||
* @api {${method}} ${item.url}
|
||||
* @apiPermission
|
||||
* @apiGroup ${item.group}
|
||||
* @apiVersion 1.0
|
||||
* @apiDescription ${item.desc}
|
||||
* @api {${method}} ${item.url} ${item.name}
|
||||
* @apiPermission none
|
||||
* @apiGroup ${item.group}
|
||||
* @apiVersion 1.0.0
|
||||
* @apiDescription ${item.desc}
|
||||
`;
|
||||
const headers = [];
|
||||
if (item.hasOwnProperty('header')) {
|
||||
item['header'].forEach(
|
||||
(item) => {
|
||||
headers.push(item);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
const common = require(resolve('./common'));
|
||||
headers.push(new common.DefaultHttpHeader());
|
||||
}
|
||||
headers.forEach(
|
||||
(header) => {
|
||||
header.fields.forEach(
|
||||
(field) => {
|
||||
this.data += ` * @apiHeader {String} ${field[0]} ${field[1]}\n`;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
if (item.is_json_params) {
|
||||
this.data += ` * @apiParamExample {json} 请求样例:\n`;
|
||||
this.data += ` * {\n`;
|
||||
this.data += ` * @apiParamExample {json} 请求样例:\n`;
|
||||
this.data += ` * {\n`;
|
||||
this.asJsonOut(item.params, 1);
|
||||
this.data += ` * }\n`;
|
||||
this.data += ` * }\n`;
|
||||
} else {
|
||||
this.asParamOut(item.params);
|
||||
}
|
||||
this.data += ' * @apiSuccessExample {json} Success-Response:\n';
|
||||
this.data += ` * HTTP/1.1 200 OK\n`;
|
||||
this.data += ` * {\n`;
|
||||
this.data += ' * @apiSuccessExample {json} Success-Response:\n';
|
||||
this.data += ` * HTTP/1.1 200 OK\n`;
|
||||
this.data += ` * {\n`;
|
||||
this.asJsonOut(item.response, 1);
|
||||
this.data += ` * }\n`;
|
||||
this.data += ` */
|
||||
this.data += ` * }\n`;
|
||||
this.data += ` */
|
||||
`;
|
||||
}
|
||||
);
|
||||
@ -85,7 +105,7 @@ class Doc
|
||||
(item) => {
|
||||
if (util.isArray(item)) {
|
||||
const paramType = this.getFieldType(item[1]);
|
||||
this.data += ` * @apiParam ${paramType} ${item[0]} ${item[2]}\n`;
|
||||
this.data += ` * @apiParam {${paramType}} ${item[0]} ${item[2]}\n`;
|
||||
} else {
|
||||
this.asParamOut(item.fields);
|
||||
}
|
||||
@ -107,13 +127,12 @@ class Doc
|
||||
const curIdent = (new Array(ident * 4)).fill(' ').join('');
|
||||
if (util.isArray(item[1])) {
|
||||
if (item[0].slice(0,1) == '!') {
|
||||
this.data += ` * ${curIdent}"${item[0].slice(1)}": [ // struct ${item[2]}\n`;
|
||||
this.data += ` * ${curIdent}"${item[0].slice(1)}": [ // struct ${item[2]}\n`;
|
||||
if (item[1].length == 1) {
|
||||
if (['string', 'number'].indexOf(typeof item[1][0]) >= 0) {
|
||||
this.data += ` * ${curIdent + IDENT}${this.getJsonValue(item[1])}\n`;
|
||||
} else {
|
||||
this.data += ` * ${curIdent + IDENT}{\n`;
|
||||
console.log(item);
|
||||
this.asJsonOut(item[1][0].fields, ident + 2);
|
||||
this.data += ` * ${curIdent + IDENT}}\n`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user