fix: swagger params handle bug

This commit is contained in:
suxiaoxin 2017-10-13 11:44:16 +08:00
parent b5fc7317f1
commit 6c06dd22a6
19 changed files with 34 additions and 43 deletions

View File

@ -27,31 +27,11 @@ YApi 是<strong>高效</strong>、<strong>易用</strong>、<strong>功能强大
#### 更新
cd {项目目录}
yapi-cli ls //查看版本号列表
yapi-cli update -v v1.1.0
yapi-cli update //更新到最新版本
yapi-cli update -v {Version} //更新到指定版本
#### 配置邮箱 (仅支持 SMTP)
打开项目目录 config.json 文件,新增 mail 配置, 替换默认的邮箱配置
```javascript
{
"port": "*****",
"adminAccount": "********",
"db": {...},
"mail": {
"enable": true,
"host": "smtp.163.com", //邮箱服务器
"port": 465, //端口
"from": "***@163.com", //发送人邮箱
"auth": {
"user": "***@163.com", //邮箱服务器账号
"pass": "*****" //邮箱服务器密码
}
}
}
```
### 在线demo
### 在线 Demo
<p><a target="_blank" href="http://yapi.demo.qunar.com">yapi.demo.qunar.com</a></p>
管理员账号

View File

@ -77,26 +77,32 @@ function improtData(importDataModule){
api.res_body = handleResponse(data.responses);
//处理参数
data.parameters.forEach(param=>{
let defaultParam = {
name: param.name,
desc: param.description,
required: param.required? "1" : "0"
}
switch(param.in){
case 'path' : api.req_params.push(defaultParam); break;
case 'query': api.req_query.push(defaultParam); break;
case 'body' : api.req_body_other = handleSchema(param.schema); break;
case 'formData' : defaultParam.type = param.type === 'file'? 'file' : 'text'; api.req_body_form.push(defaultParam); break;
case 'header' : api.req_headers.push(defaultParam);break;
}
})
if(data.parameters && Array.isArray(data.parameters)){
data.parameters.forEach(param=>{
let defaultParam = {
name: param.name,
desc: param.description,
required: param.required? "1" : "0"
}
switch(param.in){
case 'path' : api.req_params.push(defaultParam); break;
case 'query': api.req_query.push(defaultParam); break;
case 'body' : api.req_body_other = handleSchema(param.schema); break;
case 'formData' : defaultParam.type = param.type === 'file'? 'file' : 'text'; api.req_body_form.push(defaultParam); break;
case 'header' : api.req_headers.push(defaultParam);break;
}
})
}
return api;
}
function handleResponse(api){
let res_body = '';
if(!api || !Array.isArray(api)){
return res_body;
}
_.each(api, (res, code)=>{
if(code == 200 || code === 'default'){
res_body = handleSchema(res.schema);

View File

@ -1 +1 @@
window.WEBPACK_ASSETS = {"index.js":{"js":"index@69ac3d9b2a64776501a0.js","css":"index@69ac3d9b2a64776501a0.css"},"lib":{"js":"lib@f88ed246a871afd46f3e.js"},"lib2":{"js":"lib2@34c977588e1eeac462a0.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}
window.WEBPACK_ASSETS = {"index.js":{"js":"index@d40cbb31e3ed41d757d9.js","css":"index@d40cbb31e3ed41d757d9.css"},"lib":{"js":"lib@3d6790748483412d111e.js"},"lib2":{"js":"lib2@34c977588e1eeac462a0.js"},"manifest":{"js":"manifest@b67af9f8b578904e66c5.js"}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(function(e){function i(t){if(n[t])return n[t].exports;var r=n[t]={exports:{},id:t,loaded:false};e[t].call(r.exports,r,r.exports,i);r.loaded=true;return r.exports}var t=window["webpackJsonp"];window["webpackJsonp"]=function(o,u){var a,f,l=0,c=[];for(;l<o.length;l++){f=o[l];if(r[f])c.push.apply(c,r[f]);r[f]=0}for(a in u){e[a]=u[a]}if(t)t(o,u);while(c.length)c.shift().call(null,i);if(u[0]){n[0]=0;return i(0)}};var n={};var r={3:0};i.e=function(t,n){if(r[t]===0)return n.call(null,i);if(r[t]!==undefined){r[t].push(n)}else{r[t]=[n];var s=document.getElementsByTagName("head")[0];var o=document.createElement("script");o.type="text/javascript";o.charset="utf-8";o.async=true;o.src=i.p+""+t+".chunk.min.js";s.appendChild(o)}};i.m=e;i.c=n;i.p=""})([])
!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n=window.webpackJsonp;window.webpackJsonp=function(s,o){for(var u,f,l=0,c=[];l<s.length;l++)f=s[l],i[f]&&c.push.apply(c,i[f]),i[f]=0;for(u in o)e[u]=o[u];for(n&&n(s,o);c.length;)c.shift().call(null,t);if(o[0])return r[0]=0,t(0)};var r={},i={3:0};t.e=function(e,n){if(0===i[e])return n.call(null,t);if(void 0!==i[e])i[e].push(n);else{i[e]=[n];var r=document.getElementsByTagName("head")[0],s=document.createElement("script");s.type="text/javascript",s.charset="utf-8",s.async=!0,s.src=t.p+""+e+".chunk.min.js",r.appendChild(s)}},t.m=e,t.c=r,t.p=""}([])

View File

@ -166,6 +166,11 @@ module.exports = {
});
if (this.env == 'prd') {
baseConfig.plugins.push(new this.webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}))
baseConfig.plugins.push(assetsPluginInstance)
baseConfig.plugins.push(compressPlugin)