This commit is contained in:
azw 2023-09-03 15:36:55 +08:00
parent 719009b7f2
commit 910dc1ce7c
2 changed files with 13 additions and 7 deletions

View File

@ -27,11 +27,12 @@ module.exports = class {
'desc': '用户登录',
'group': 'User',
'url': 'api/v1/user/info/:user_id',
'is_json_params': true,
'params': [
['!rsp', [new common.RspHead()], 'ok rsp']
],
'response': [
new common.RspHead(),
['rsp', new common.RspHead(), 'ok rsp']
]
},
];

View File

@ -53,7 +53,7 @@ class Doc
* @apiDescription ${item.desc}
`;
if (item.is_json_params) {
this.data += ` * @apiParamExample {json} 请求样例:\n`;
this.data += ` * @apiParamExample {json} 请求样例:\n`;
this.data += ` * {\n`;
this.asJsonOut(item.params, 1);
this.data += ` * }\n`;
@ -117,11 +117,16 @@ class Doc
this.data += ` * ${curIdent}'${item[0]}': { // struct ${item[2]}\n`;
}
} else {
if (['string', 'number'].indexOf(typeof item[1]) >= 0) {
const paramType = this.getFieldType(item[1]);
this.data += ` * ${curIdent}'${item[0]}': ${this.getJsonValue(item[1])}, //${item[2]}\n`;
} else {
console.log(11111111111, item, item.__proto__.name);
if (util.isArray(item)) {
if (['string', 'number'].indexOf(typeof item[1]) >= 0) {
const paramType = this.getFieldType(item[1]);
this.data += ` * ${curIdent}'${item[0]}': ${this.getJsonValue(item[1])}, //${item[2]}\n`;
} else {
this.data += ` * ${curIdent}'${item[0]}': { // struct ${item[1].constructor.name} ${item[2]}\n`;
this.asJsonOut(item[1].fields, ident + 1);
this.data += ` * ${curIdent}}\n`;
}
} else if (typeof item == 'object'){
this.asJsonOut(item.fields, ident);
}
}