mirror of
https://github.com/YMFE/yapi.git
synced 2024-11-27 04:40:08 +08:00
fix: 修复导出格式错误问题
This commit is contained in:
parent
06a8766bd9
commit
20dee61803
@ -4,12 +4,14 @@
|
||||
* 支持swagger URL 导入
|
||||
* 接口运行和测试集合中加入参数备注信息
|
||||
* 测试接口导入支持状态过滤
|
||||
* json schema 增加枚举备注功能
|
||||
|
||||
#### Bug Fixed
|
||||
|
||||
* 修复测试用例名称为空时保存测试用例出现的bug
|
||||
* 导出markdown 路径参数处格式错误
|
||||
* json schema 增加枚举备注功能
|
||||
* 导出markdown 路径参数处格式错误和参数table备注信息换行后样式错误
|
||||
|
||||
|
||||
|
||||
### v1.3.18
|
||||
|
||||
|
85
a.markdown
85
a.markdown
@ -12,24 +12,37 @@
|
||||
|
||||
### 基本信息
|
||||
|
||||
**Path:** /api/col/list
|
||||
**Path:** /api/col/list{id}
|
||||
|
||||
**Method:** GET
|
||||
**Method:** POST
|
||||
|
||||
**接口描述:**
|
||||
|
||||
|
||||
### 请求参数
|
||||
**Headers**
|
||||
|
||||
| 参数名称 | 参数值 | 是否必须 | 示例 | 备注 |
|
||||
| ------------ | ------------ | ------------ | ------------ | ------------ |
|
||||
| Content-Type | application/x-www-form-urlencoded | 是 | | |
|
||||
| Accept | 1234 | 是 | 12<br/>33<br/><br/>444 | 233<br/>444<br/>444<br/>444 |
|
||||
**路径参数**
|
||||
|
||||
| 参数名称 | 示例 | 备注 |
|
||||
| ------------ | ------------ | ------------ | ------------ | ------------ |
|
||||
| id | 1<br/>2<br/>3<br/>4 | 4<br/>5<br/>5 |
|
||||
**Query**
|
||||
|
||||
| 参数名称 | 是否必须 | 示例 | 备注 |
|
||||
| ------------ | ------------ | ------------ | ------------ |
|
||||
| name | 是 | | 12
|
||||
33
|
||||
44
|
||||
66
|
||||
7
|
||||
77 |
|
||||
| nameweueueuueueueueueueueueueueueue | 是 | 34<br/>55<br/>66<br/>66<br/> | 12<br/>33<br/>44<br/>66<br/>7<br/>77 |
|
||||
**Body**
|
||||
|
||||
| 参数名称 | 参数类型 | 是否必须 | 示例 | 备注 |
|
||||
| ------------ | ------------ | ------------ | ------------ | ------------ |
|
||||
| dududueueueiwiwiwuueueuddjdjd | text | 是 | | |
|
||||
|
||||
|
||||
|
||||
### 返回数据
|
||||
|
||||
@ -38,16 +51,66 @@
|
||||
<tr>
|
||||
<th key=name>名称</th><th key=type>类型</th><th key=required>是否必须</th><th key=default>默认值</th><th key=desc>备注</th><th key=sub>其他信息</th>
|
||||
</tr>
|
||||
</thead><tbody className="ant-table-tbody"><tr key=0-0><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_1</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span>wweeewee</span></td><td key=5></td></tr><tr key=0-1><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_2</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span>eeeeweqq</span></td><td key=5></td></tr><tr key=0-2><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_3</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span>weqqwwwee</span></td><td key=5></td></tr><tr key=0-3><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_4</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span>weewq</span></td><td key=5></td></tr><tr key=0-4><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_9</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span></span></td><td key=5></td></tr><tr key=0-5><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_10</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span></span></td><td key=5></td></tr><tr key=0-6><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_8</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span>12</span></td><td key=5></td></tr><tr key=0-7><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_7</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span>1
|
||||
</thead><tbody className="ant-table-tbody"><tr key=0-0><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_1</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">wweeewee</span></td><td key=5></td></tr><tr key=0-1><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_2</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">eeeeweqq</span></td><td key=5></td></tr><tr key=0-2><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_3</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">weqqwwwee</span></td><td key=5></td></tr><tr key=0-3><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_4</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">weewq</span></td><td key=5></td></tr><tr key=0-4><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_9</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap"></span></td><td key=5></td></tr><tr key=0-5><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_10</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap"></span></td><td key=5></td></tr><tr key=0-6><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_8</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">12</span></td><td key=5></td></tr><tr key=0-7><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_7</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">1
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7</span></td><td key=5></td></tr><tr key=0-8><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_6</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span>1
|
||||
7</span></td><td key=5></td></tr><tr key=0-8><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_6</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">1
|
||||
12
|
||||
12
|
||||
12
|
||||
12</span></td><td key=5></td></tr><tr key=0-9><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_13</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span></span></td><td key=5></td></tr><tr key=0-10><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_12</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span></span></td><td key=5></td></tr><tr key=0-11><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_11</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span></span></td><td key=5></td></tr>
|
||||
12</span></td><td key=5><p key=2><span style="font-weight: '700'">枚举: </span><span>1,2,3</span></p><p key=3><span style="font-weight: '700'">枚举备注: </span><span>1: qrn
|
||||
2: we
|
||||
3:yis</span></p></td></tr><tr key=0-9><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_13</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap"></span></td><td key=5></td></tr><tr key=0-10><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_12</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap"></span></td><td key=5></td></tr><tr key=0-11><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_11</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap"></span></td><td key=5></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## get%0A%3Ca%20id%3Dget%3E%20%3C/a%3E
|
||||
[TOC]
|
||||
|
||||
### 基本信息
|
||||
|
||||
**Path:** /app/code
|
||||
|
||||
**Method:** GET
|
||||
|
||||
**接口描述:**
|
||||
|
||||
|
||||
### 请求参数
|
||||
**Headers**
|
||||
|
||||
| 参数名称 | 参数值 | 是否必须 | 示例 | 备注 |
|
||||
| ------------ | ------------ | ------------ | ------------ | ------------ |
|
||||
| Accept-Charset | application/json | 是 | | |
|
||||
**Query**
|
||||
|
||||
| 参数名称 | 是否必须 | 示例 | 备注 |
|
||||
| ------------ | ------------ | ------------ | ------------ |
|
||||
| a | 是 | | |
|
||||
| project_id | 是 | | |
|
||||
|
||||
### 返回数据
|
||||
|
||||
<table>
|
||||
<thead class="ant-table-thead">
|
||||
<tr>
|
||||
<th key=name>名称</th><th key=type>类型</th><th key=required>是否必须</th><th key=default>默认值</th><th key=desc>备注</th><th key=sub>其他信息</th>
|
||||
</tr>
|
||||
</thead><tbody className="ant-table-tbody"><tr key=0-0><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> name</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3>小明</td><td key=4><span style="white-space: pre-wrap">12
|
||||
12
|
||||
12
|
||||
12</span></td><td key=5></td></tr><tr key=0-1><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_18</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap"></span></td><td key=5></td></tr><tr key=0-2><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> age</span></td><td key=1><span>number</span></td><td key=2>非必须</td><td key=3>20</td><td key=4><span style="white-space: pre-wrap">32
|
||||
23
|
||||
23</span></td><td key=5></td></tr><tr key=0-3><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_19</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">we
|
||||
we
|
||||
we
|
||||
we</span></td><td key=5></td></tr><tr key=0-4><td key=0><span style="padding-left: 0px"><span style="color: #8c8a8a"></span> field_20</span></td><td key=1><span>string</span></td><td key=2>非必须</td><td key=3></td><td key=4><span style="white-space: pre-wrap">werr
|
||||
rrr
|
||||
rrr
|
||||
r
|
||||
rrrr</span></td><td key=5></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -79,7 +79,6 @@ const columns = [
|
||||
dataIndex: 'sub',
|
||||
key: 'sub',
|
||||
render: text => {
|
||||
console.log(text)
|
||||
return Object.keys(text || []).map((item, index) => {
|
||||
let name = messageMap[item];
|
||||
let value = text[item];
|
||||
@ -88,7 +87,7 @@ const columns = [
|
||||
!_.isUndefined(text[item]) && (
|
||||
<p key={index}>
|
||||
<span style={{ fontWeight: '700' }}>{name}: </span>
|
||||
<span className="table-desc">{value.toString()}</span>
|
||||
<span >{value.toString()}</span>
|
||||
</p>
|
||||
)
|
||||
);
|
||||
|
@ -575,7 +575,7 @@ class InterfaceEditForm extends Component {
|
||||
<Col span="4" draggable="false" className="interface-edit-item-content-col">
|
||||
{getFieldDecorator('req_query[' + index + '].name', {
|
||||
initialValue: data.name
|
||||
})(<TextArea autosize={{ minRows: 1, maxRows: 1 }} placeholder="参数名称" />)}
|
||||
})(<Input placeholder="参数名称" />)}
|
||||
</Col>
|
||||
<Col span="3" className="interface-edit-item-content-col">
|
||||
{getFieldDecorator('req_query[' + index + '].required', {
|
||||
@ -634,7 +634,7 @@ class InterfaceEditForm extends Component {
|
||||
<Col span="5" className="interface-edit-item-content-col">
|
||||
{getFieldDecorator('req_headers[' + index + '].value', {
|
||||
initialValue: data.value
|
||||
})(<TextArea autosize={{ minRows: 1, maxRows: 1 }} placeholder="参数值" />)}
|
||||
})(<Input placeholder="参数值" />)}
|
||||
</Col>
|
||||
<Col span="5" className="interface-edit-item-content-col">
|
||||
{getFieldDecorator('req_headers[' + index + '].example', {
|
||||
@ -670,7 +670,7 @@ class InterfaceEditForm extends Component {
|
||||
<Col span="4" className="interface-edit-item-content-col">
|
||||
{getFieldDecorator('req_body_form[' + index + '].name', {
|
||||
initialValue: data.name
|
||||
})(<TextArea autosize={{ minRows: 1, maxRows: 1 }} placeholder="name" />)}
|
||||
})(<Input placeholder="name" />)}
|
||||
</Col>
|
||||
<Col span="3" className="interface-edit-item-content-col">
|
||||
{getFieldDecorator('req_body_form[' + index + '].type', {
|
||||
|
@ -8,6 +8,12 @@ const json_parse = function(json){
|
||||
return {};
|
||||
}
|
||||
}
|
||||
// 处理字符串换行
|
||||
const handleWrap = (str) => {
|
||||
|
||||
return _.isString(str) ? str.replace(/\n/gi, '<br/>') : str
|
||||
|
||||
}
|
||||
const messageMap = {
|
||||
desc: '备注',
|
||||
default: '实例',
|
||||
@ -20,7 +26,8 @@ const messageMap = {
|
||||
uniqueItems: '元素是否都不同',
|
||||
itemType: 'item 类型',
|
||||
format: 'format',
|
||||
enum: '枚举'
|
||||
enum: '枚举',
|
||||
enumDesc: '枚举备注'
|
||||
};
|
||||
|
||||
const columns = [
|
||||
@ -76,7 +83,7 @@ function createReqHeaders(req_headers) {
|
||||
for (let j = 0; j < req_headers.length; j++) {
|
||||
headersTable += `| ${req_headers[j].name || ''} | ${req_headers[j].value || ''} | ${
|
||||
req_headers[j].required == 1 ? '是' : '否'
|
||||
} | ${req_headers[j].example || ''} | ${req_headers[j].desc || ''} |\n`;
|
||||
} | ${handleWrap(req_headers[j].example) || ''} | ${handleWrap(req_headers[j].desc) || ''} |\n`;
|
||||
}
|
||||
return headersTable;
|
||||
}
|
||||
@ -88,8 +95,8 @@ function createPathParams(req_params) {
|
||||
let paramsTable = `**路径参数**\n\n`;
|
||||
paramsTable += `| 参数名称 | 示例 | 备注 |\n| ------------ | ------------ | ------------ | ------------ | ------------ |\n`;
|
||||
for (let j = 0; j < req_params.length; j++) {
|
||||
paramsTable += `| ${req_params[j].name || ''} | ${req_params[j].example ||
|
||||
''} | ${req_params[j].desc || ''} |\n`;
|
||||
paramsTable += `| ${req_params[j].name || ''} | ${handleWrap(req_params[j].example) ||
|
||||
''} | ${handleWrap(req_params[j].desc) || ''} |\n`;
|
||||
}
|
||||
return paramsTable;
|
||||
}
|
||||
@ -97,14 +104,14 @@ function createPathParams(req_params) {
|
||||
}
|
||||
|
||||
function createReqQuery(req_query) {
|
||||
// console.log("req_query", req_query);
|
||||
|
||||
if (req_query && req_query.length) {
|
||||
let headersTable = `**Query**\n\n`;
|
||||
headersTable += `| 参数名称 | 是否必须 | 示例 | 备注 |\n| ------------ | ------------ | ------------ | ------------ |\n`;
|
||||
for (let j = 0; j < req_query.length; j++) {
|
||||
headersTable += `| ${req_query[j].name || ''} | ${
|
||||
req_query[j].required == 1 ? '是' : '否'
|
||||
} | ${req_query[j].example || ''} | ${req_query[j].desc || ''} |\n`;
|
||||
} | ${handleWrap(req_query[j].example) || ''} | ${handleWrap(req_query[j].desc) || ''} |\n`;
|
||||
}
|
||||
return headersTable;
|
||||
}
|
||||
@ -180,8 +187,8 @@ function tableCol(col, columns, level) {
|
||||
break;
|
||||
case 'desc':
|
||||
text = _.isUndefined(col.childrenDesc)
|
||||
? `<span>${value}</span>`
|
||||
: `<span>${col.childrenDesc}</span>`;
|
||||
? `<span style="white-space: pre-wrap">${value}</span>`
|
||||
: `<span style="white-space: pre-wrap">${col.childrenDesc}</span>`;
|
||||
break;
|
||||
case 'name':
|
||||
text = `<span style="padding-left: ${20*level}px"><span style="color: #8c8a8a">${level>0 ? '├─':'' }</span> ${value}</span>`;
|
||||
|
Loading…
Reference in New Issue
Block a user