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