This commit is contained in:
azw 2023-09-03 15:56:38 +08:00
parent 910dc1ce7c
commit 0a5b9d3c8e

View File

@ -60,6 +60,11 @@ class Doc
} else {
this.asParamOut(item.params);
}
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 += ` */
`;
}
@ -102,27 +107,29 @@ class Doc
const curIdent = (new Array(ident * 4)).fill(' ').join('');
if (util.isArray(item[1])) {
if (item[0].slice(0,1) == '!') {
const realFieldName = item[0].slice(1);
this.data += ` * ${curIdent}'${realFieldName}': [ // struct ${item[2]}\n`;
this.data += ` * ${curIdent}"${item[0].slice(1)}": [ // struct ${item[2]}\n`;
if (item[1].length == 1) {
if (util.isArray(item[1][0])) {
this.data += ` * ${curIdent + IDENT}'${realFieldName}': [ // struct ${item[2]}\n`;
} else {
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`;
}
} else {
}
this.data += ` * ${curIdent}]\n`;
} else {
this.data += ` * ${curIdent}'${item[0]}': { // struct ${item[2]}\n`;
this.data += ` * ${curIdent}"${item[0]}": { // struct ${item[2]}\n`;
}
} else {
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`;
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.data += ` * ${curIdent}"{item[0]}": { // struct ${item[1].constructor.name} ${item[2]}\n`;
this.asJsonOut(item[1].fields, ident + 1);
this.data += ` * ${curIdent}}\n`;
}