MCPcopy
hub / github.com/YMFE/yapi / createReqBody

Function createReqBody

common/markdown.js:121–142  ·  view source on GitHub ↗
(req_body_type, req_body_form, req_body_other, req_body_is_json_schema)

Source from the content-addressed store, hash-verified

119}
120
121function createReqBody(req_body_type, req_body_form, req_body_other, req_body_is_json_schema) {
122 if (req_body_type === 'form' && req_body_form.length) {
123 let bodyTable = `**Body**\n\n`;
124 bodyTable += `| 参数名称 | 参数类型 | 是否必须 | 示例 | 备注 |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n`;
125 let req_body = req_body_form;
126 for (let j = 0; j < req_body.length; j++) {
127 bodyTable += `| ${req_body[j].name || ''} | ${req_body[j].type || ''} | ${
128 req_body[j].required == 1 ? '是' : '否'
129 } | ${req_body[j].example || ''} | ${req_body[j].desc || ''} |\n`;
130 }
131 return `${bodyTable}\n\n`;
132 } else if (req_body_other) {
133 if (req_body_is_json_schema) {
134 let reqBody = createSchemaTable(req_body_other);
135 return `**Body**\n\n` + reqBody;
136 } else {
137 //other
138 return `**Body**\n\n` + '```javascript' + `\n${req_body_other || ''}` + '\n```';
139 }
140 }
141 return '';
142}
143
144function tableHeader(columns) {
145 let header = ``;

Callers 1

createInterMarkdownFunction · 0.85

Calls 1

createSchemaTableFunction · 0.85

Tested by

no test coverage detected