openapi接口文档解析支持

This commit is contained in:
暮光:城中城
2021-12-28 23:58:43 +08:00
parent bc7ae4fc67
commit 74b1b417ad
34 changed files with 196 additions and 3150 deletions

View File

@@ -150,9 +150,10 @@ public class ApiDocumentController {
} else { } else {
apiDocService.saveOrUpdate(apiDoc); apiDocService.saveOrUpdate(apiDoc);
} }
} else if (Objects.equals(apiDoc.getDocType(), 2) || Objects.equals(apiDoc.getDocType(), 4)) { } else if (Objects.equals(apiDoc.getDocType(), 2)
apiDocService.saveOrUpdate(apiDoc); || Objects.equals(apiDoc.getDocType(), 3)
} else if (Objects.equals(apiDoc.getDocType(), 5)) { || Objects.equals(apiDoc.getDocType(), 4)
|| Objects.equals(apiDoc.getDocType(), 5)) {
apiDocService.saveOrUpdate(apiDoc); apiDocService.saveOrUpdate(apiDoc);
} else { } else {
return DocResponseJson.warn("暂不支持的文档类型"); return DocResponseJson.warn("暂不支持的文档类型");
@@ -207,7 +208,7 @@ public class ApiDocumentController {
if (!apiDocAuthJudgeService.haveDevelopAuth(apiDoc)) { if (!apiDocAuthJudgeService.haveDevelopAuth(apiDoc)) {
return DocResponseJson.warn("没有此文档的查看权限"); return DocResponseJson.warn("没有此文档的查看权限");
} }
if (Objects.equals(apiDoc.getDocType(), 1)) { if (Objects.equals(apiDoc.getDocType(), 1) || Objects.equals(apiDoc.getDocType(), 3)) {
try { try {
String docsDomain = SwaggerDocUtil.getV2ApiDocsDomain(apiDoc.getDocUrl()); String docsDomain = SwaggerDocUtil.getV2ApiDocsDomain(apiDoc.getDocUrl());
String contentStr = swaggerHttpRequestService.requestSwaggerUrl(request, apiDoc.getId(), apiDoc.getDocUrl(), docsDomain); String contentStr = swaggerHttpRequestService.requestSwaggerUrl(request, apiDoc.getId(), apiDoc.getDocUrl(), docsDomain);

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

View File

@@ -1 +0,0 @@
import{u as S,ar as w,r as c,o as a,c as l,w as t,a as o,m as g,t as n,b as i,F as f,k as s,e as m,d as M}from"./vendor.948fa90f.js";import{m as B}from"./index.b99389a4.js";import{_ as C}from"./main.92a9e84b.js";const N={setup(){const _=S(),D=w(()=>_.state.swaggerDoc),u=w(()=>_.state.swaggerDoc.info),e=w(()=>_.state.swaggerMethodStatistic);return{swaggerDoc:D,swaggerDocInfo:u,swaggerMethodStatistic:e,getDescription:I=>B.exports.markdownIt.render(I||"")}}},V=["href"],j=["href"],L=["href"],O=["innerHTML"],T={key:1,style:{"text-align":"center"}};function E(_,D,u,e,p,I){const r=c("a-form-item"),h=c("a-divider"),b=c("a-statistic"),k=c("a-card"),v=c("a-col"),y=c("a-row"),x=c("a-form");return a(),l(k,null,{default:t(()=>[e.swaggerDocInfo?(a(),l(x,{key:0,"label-col":{span:4},"wrapper-col":{span:20}},{default:t(()=>[o(r,{label:"\u6807\u9898"},{default:t(()=>[g(n(e.swaggerDocInfo.title),1)]),_:1}),o(r,{label:"\u7248\u672C"},{default:t(()=>[g(n(e.swaggerDocInfo.version),1)]),_:1}),e.swaggerDocInfo.contact?(a(),l(r,{key:0,label:"\u4F5C\u8005"},{default:t(()=>[e.swaggerDocInfo.contact.name?(a(),i(f,{key:0},[g(n(e.swaggerDocInfo.contact.name),1)],64)):s("",!0),e.swaggerDocInfo.contact.email?(a(),i(f,{key:1},[o(h,{type:"vertical"}),g(n(e.swaggerDocInfo.contact.email),1)],64)):s("",!0),e.swaggerDocInfo.contact.url?(a(),i(f,{key:2},[o(h,{type:"vertical"}),m("a",{href:e.swaggerDocInfo.contact.url,target:"_blank"},n(e.swaggerDocInfo.contact.url),9,V)],64)):s("",!0)]),_:1})):s("",!0),o(r,{label:"host"},{default:t(()=>[g(n(e.swaggerDoc.host),1)]),_:1}),e.swaggerDocInfo.license?(a(),l(r,{key:1,label:"\u8BB8\u53EF\u8BC1"},{default:t(()=>[m("a",{href:e.swaggerDocInfo.license.url,target:"_blank"},n(e.swaggerDocInfo.license.name),9,j)]),_:1})):s("",!0),e.swaggerDocInfo.termsOfService?(a(),l(r,{key:2,label:"\u670D\u52A1\u6761\u6B3E"},{default:t(()=>[m("a",{href:e.swaggerDocInfo.termsOfService,target:"_blank"},n(e.swaggerDocInfo.termsOfService),9,L)]),_:1})):s("",!0),o(r,{label:"\u6587\u6863\u8BF4\u660E"},{default:t(()=>[m("div",{class:"markdown-body",innerHTML:e.getDescription(e.swaggerDocInfo.description)},null,8,O)]),_:1}),o(r,{label:"\u63A5\u53E3\u7EDF\u8BA1"},{default:t(()=>[o(y,{gutter:[16,16]},{default:t(()=>[(a(),i(f,null,M(["get","post","put","delete","head","patch","options","trace","total"],d=>(a(),i(f,null,[e.swaggerMethodStatistic[d]?(a(),l(v,{key:0,span:6},{default:t(()=>[o(k,{size:"small"},{default:t(()=>[o(b,{title:d==="total"?"\u603B\u8BA1":d.toUpperCase()+"\u65B9\u6CD5",value:e.swaggerMethodStatistic[d],suffix:"\u4E2A"},null,8,["title","value"])]),_:2},1024)]),_:2},1024)):s("",!0)],64))),64))]),_:1})]),_:1})]),_:1})):(a(),i("div",T,"\u6682\u65E0\u6587\u6863\u4FE1\u606F\uFF0C\u8BF7\u5148\u9009\u62E9\u6587\u6863"))]),_:1})}var U=C(N,[["render",E]]);export{U as default};

View File

@@ -1 +0,0 @@
import{u as S,ar as D,r,o as t,c as l,w as o,a as n,m as s,t as c,b as p,F as f,k as i,e as m,d as w}from"./vendor.948fa90f.js";import{m as M}from"./index.b99389a4.js";import{_ as B}from"./main.92a9e84b.js";const C={setup(){const _=S(),A=D(()=>_.state.openApiDoc),u=D(()=>_.state.openApiDoc.info),e=D(()=>_.state.openApiMethodStatistic);return{openApiDoc:A,openApiDocInfo:u,openApiMethodStatistic:e,getDescription:I=>M.exports.markdownIt.render(I||"")}}},N=["href"],V=["href"],j=["href"],L=["innerHTML"],O={key:1,style:{"text-align":"center"}};function T(_,A,u,e,b,I){const a=r("a-form-item"),h=r("a-divider"),v=r("a-statistic"),k=r("a-card"),y=r("a-col"),g=r("a-row"),x=r("a-form");return t(),l(k,null,{default:o(()=>[e.openApiDocInfo?(t(),l(x,{key:0,"label-col":{span:4},"wrapper-col":{span:20}},{default:o(()=>[n(a,{label:"\u6807\u9898"},{default:o(()=>[s(c(e.openApiDocInfo.title),1)]),_:1}),n(a,{label:"\u7248\u672C"},{default:o(()=>[s(c(e.openApiDocInfo.version),1)]),_:1}),e.openApiDocInfo.contact?(t(),l(a,{key:0,label:"\u4F5C\u8005"},{default:o(()=>[e.openApiDocInfo.contact.name?(t(),p(f,{key:0},[s(c(e.openApiDocInfo.contact.name),1)],64)):i("",!0),e.openApiDocInfo.contact.email?(t(),p(f,{key:1},[n(h,{type:"vertical"}),s(c(e.openApiDocInfo.contact.email),1)],64)):i("",!0),e.openApiDocInfo.contact.url?(t(),p(f,{key:2},[n(h,{type:"vertical"}),m("a",{href:e.openApiDocInfo.contact.url,target:"_blank"},c(e.openApiDocInfo.contact.url),9,N)],64)):i("",!0)]),_:1})):i("",!0),n(a,{label:"host"},{default:o(()=>[s(c(e.openApiDoc.host),1)]),_:1}),e.openApiDocInfo.license?(t(),l(a,{key:1,label:"\u8BB8\u53EF\u8BC1"},{default:o(()=>[m("a",{href:e.openApiDocInfo.license.url,target:"_blank"},c(e.openApiDocInfo.license.name),9,V)]),_:1})):i("",!0),e.openApiDocInfo.termsOfService?(t(),l(a,{key:2,label:"\u670D\u52A1\u6761\u6B3E"},{default:o(()=>[m("a",{href:e.openApiDocInfo.termsOfService,target:"_blank"},c(e.openApiDocInfo.termsOfService),9,j)]),_:1})):i("",!0),n(a,{label:"\u6587\u6863\u8BF4\u660E"},{default:o(()=>[m("div",{class:"markdown-body",innerHTML:e.getDescription(e.openApiDocInfo.description)},null,8,L)]),_:1}),n(a,{label:"\u63A5\u53E3\u7EDF\u8BA1"},{default:o(()=>[n(g,{gutter:[16,16]},{default:o(()=>[(t(),p(f,null,w(["get","post","put","delete","head","patch","options","trace","total"],d=>(t(),p(f,null,[e.openApiMethodStatistic[d]?(t(),l(y,{key:0,span:6},{default:o(()=>[n(k,{size:"small"},{default:o(()=>[n(v,{title:d==="total"?"\u603B\u8BA1":d.toUpperCase()+"\u65B9\u6CD5",value:e.openApiMethodStatistic[d],suffix:"\u4E2A"},null,8,["title","value"])]),_:2},1024)]),_:2},1024)):i("",!0)],64))),64))]),_:1})]),_:1})]),_:1})):(t(),p("div",O,"\u6682\u65E0\u6587\u6863\u4FE1\u606F\uFF0C\u8BF7\u5148\u9009\u62E9\u6587\u6863"))]),_:1})}var z=B(C,[["render",T]]);export{z as default};

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
import{v as y,u as j,y as n,H as D,r as h,o as g,c as v,w as k,B as w,e as x}from"./vendor.948fa90f.js";import{D as I,o as _}from"./DocContent.4b703d6b.js";import{m as M}from"./index.b99389a4.js";import{_ as b}from"./main.92a9e84b.js";import"./logUtil.24f55f0f.js";const q={components:{DocContent:I},setup(){const a=y(),t=j();let p=n("doc"),o=n([]),r=n([]),i=n({url:"",description:"",method:"",consumes:"",produces:""}),s=n(!1),c=0,l;const m=()=>{let P=a.query.path+"."+a.query.method;if(Object.keys(t.state.openApiUrlMethodMap).length<=0){console.log("\u6587\u6863\u5C1A\u672A\u52A0\u8F7D\uFF0C\u7B49\u5F85\u52A0\u8F7D\u5B8C\u6210"),l||(l=setInterval(()=>{if(s.value||c++>50){clearInterval(l);return}Object.keys(t.state.openApiUrlMethodMap).length>0&&(console.log("\u6587\u6863\u5185\u5BB9\u6539\u53D8\uFF0C\u91CD\u65B0\u52A0\u8F7D\u6587\u6863"),m())},1e3));return}let e=t.state.openApiUrlMethodMap[P];if(!e){w.error("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u6587\u6863");return}s.value=!0,t.commit("addTableName",{key:a.fullPath,val:e.summary});let u="",d="";e.consumes&&e.consumes.length>0&&(u=e.consumes.join(" ")),e.produces&&e.produces.length>0&&(d=e.produces.join(" "));let L=M.exports.markdownIt.render(e.description||e.summary||"");i.value={url:e.url,description:L,method:e.method||"",consumes:u,produces:d};let f=t.state.openApiDefinitions;o.value=_.getRequestParamList(e.parameters,f),r.value=_.getResponseParamList(e.responses,f)};return D(()=>{m()}),{docInfoShow:i,activePage:p,changePage:()=>{},isLoadSuccess:s,requestParamList:o,responseParamList:r}}},S=x("div",{style:{padding:"20px 0",height:"100px"}},null,-1);function A(a,t,p,o,r,i){const s=h("DocContent"),c=h("a-spin");return o.isLoadSuccess?(g(),v(s,{key:0,docInfoShow:o.docInfoShow,requestParamList:o.requestParamList,responseParamList:o.responseParamList},null,8,["docInfoShow","requestParamList","responseParamList"])):(g(),v(c,{key:1,tip:"\u6587\u6863\u6570\u636E\u52A0\u8F7D\u4E2D..."},{default:k(()=>[S]),_:1}))}var T=b(q,[["render",A]]);export{T as default};

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
import{v as L,u as y,y as a,H as j,r as g,o as h,c as v,w as D,B as k,e as x}from"./vendor.948fa90f.js";import{D as I,s as _}from"./DocContent.2911adec.js";import{m as M}from"./index.b99389a4.js";import{_ as q}from"./main.92a9e84b.js";import"./logUtil.24f55f0f.js";const S={components:{DocContent:I},setup(){const r=L(),s=y();let m=a("doc"),t=a([]),n=a([]),c=a({url:"",description:"",method:"",consumes:"",produces:""}),o=a(!1),i=0,l;const u=()=>{let P=r.query.path+"."+r.query.method;if(Object.keys(s.state.swaggerUrlMethodMap).length<=0){console.log("\u6587\u6863\u5C1A\u672A\u52A0\u8F7D\uFF0C\u7B49\u5F85\u52A0\u8F7D\u5B8C\u6210"),l||(l=setInterval(()=>{if(o.value||i++>50){clearInterval(l);return}Object.keys(s.state.swaggerUrlMethodMap).length>0&&(console.log("\u6587\u6863\u5185\u5BB9\u6539\u53D8\uFF0C\u91CD\u65B0\u52A0\u8F7D\u6587\u6863"),u())},1e3));return}let e=s.state.swaggerUrlMethodMap[P];if(!e){k.error("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u6587\u6863");return}o.value=!0,s.commit("addTableName",{key:r.fullPath,val:e.summary});let d="",p="";e.consumes&&e.consumes.length>0&&(d=e.consumes.join(" ")),e.produces&&e.produces.length>0&&(p=e.produces.join(" "));let w=M.exports.markdownIt.render(e.description||e.summary||"");c.value={url:e.url,description:w,method:e.method||"",consumes:d,produces:p};let f=s.state.swaggerDefinitions;t.value=_.getRequestParamList(e.parameters,f),n.value=_.getResponseParamList(e.responses,f)};return j(()=>{u()}),{docInfoShow:c,activePage:m,changePage:()=>{},isLoadSuccess:o,requestParamList:t,responseParamList:n}}},C=x("div",{style:{padding:"20px 0",height:"100px"}},null,-1);function b(r,s,m,t,n,c){const o=g("DocContent"),i=g("a-spin");return t.isLoadSuccess?(h(),v(o,{key:0,docInfoShow:t.docInfoShow,requestParamList:t.requestParamList,responseParamList:t.responseParamList},null,8,["docInfoShow","requestParamList","responseParamList"])):(h(),v(i,{key:1,tip:"\u6587\u6863\u6570\u636E\u52A0\u8F7D\u4E2D..."},{default:D(()=>[C]),_:1}))}var V=q(S,[["render",b]]);export{V as default};

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
var K=Object.defineProperty;var I=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var B=(s,e,a)=>e in s?K(s,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[e]=a,x=(s,e)=>{for(var a in e||(e={}))N.call(e,a)&&B(s,a,e[a]);if(I)for(var a of I(e))O.call(e,a)&&B(s,a,e[a]);return s};import{z as V}from"./custom.6a6c45c1.js";import{P as S,Z as U,a3 as j,u as A,y as L,H as F,r as m,o as l,b as u,e as z,a as d,w as n,F as f,c as k,t as G,k as b,B as H,m as c}from"./vendor.948fa90f.js";import{_ as R}from"./main.92a9e84b.js";const q={components:{PlusOutlined:S,SearchOutlined:U,ReloadOutlined:j},props:{dynamicParam:{type:Object,required:!0}},setup(s){const e=A();let a=L([]),t=L(!1);const h=async()=>{i.value={},t.value=!0,V.docApiGlobalParamList(s.dynamicParam).then(o=>{setTimeout(()=>t.value=!1,500),a.value=o.data||[],e.commit("setGlobalParamOnChange",a.value,s.dynamicParam.id)})};let i=L({}),D=L();const p=()=>{i.value.isEdit&&v(i.value);let o={isEdit:!0,paramType:1};a.value.unshift(o),i.value=o,setTimeout(()=>{let r=document.getElementsByClassName("ant-table-body")[0];r.scrollTop=0},0)},P=o=>{i.value.isEdit&&v(i.value),o.isEdit=!0,i.value=x({},o)},v=o=>{o.isEdit=!1,o.id?a.value.forEach(r=>r.isEdit=!1):a.value=a.value.filter(r=>r!==o),i.value={}},E=o=>{if(!i.value.paramKey||!i.value.paramValue){H.error("\u53C2\u6570\u540D\u6216\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A");return}let r=x(x({},s.dynamicParam),i.value);V.docApiGlobalParamUpdate(r).then(w=>{o.isEdit=!1,h()})},T=async o=>{V.docApiGlobalParamUpdate({id:o.id,yn:0}).then(r=>{h()})};return F(()=>{h()}),{docList:a,docListLoading:t,docEdit:i,tableRef:D,searchDocList:h,deleteDoc:T,editDoc:P,saveEditDoc:E,cancelEditDoc:v,addDocLine:p,docListColumns:[{title:"\u53C2\u6570\u540D\u79F0",dataIndex:"paramKey",width:250},{title:"\u53C2\u6570\u503C",dataIndex:"paramValue"},{title:"\u53C2\u6570\u4F4D\u7F6E",dataIndex:"paramType",width:120},{title:"\u64CD\u4F5C",dataIndex:"operation",fixed:"right",width:170}]}}},M={style:{"margin-bottom":"10px","text-align":"right"}},Z=c(" \u5237\u65B0"),J=c(" \u65B0\u5EFA"),Q={key:1},W={key:1},X=c("Form"),Y=c("Header"),$=c("Cookie"),ee=c("Form"),ae=c("Header"),te=c("Cookie"),oe=c("\u53D6\u6D88"),ne=c("\u4FDD\u5B58"),le=c("\u7F16\u8F91"),ie=c("\u5220\u9664");function de(s,e,a,t,h,i){const D=m("reload-outlined"),p=m("a-button"),P=m("plus-outlined"),v=m("a-input"),E=m("a-select-option"),T=m("a-select"),o=m("a-tag"),r=m("a-popconfirm"),w=m("a-table");return l(),u(f,null,[z("div",M,[d(p,{onClick:t.searchDocList,type:"primary"},{icon:n(()=>[d(D)]),default:n(()=>[Z]),_:1},8,["onClick"]),d(p,{onClick:t.addDocLine},{icon:n(()=>[d(P)]),default:n(()=>[J]),_:1},8,["onClick"])]),d(w,{dataSource:t.docList,columns:t.docListColumns,size:"middle",id:"paramTable",loading:t.docListLoading,pagination:!1,scroll:{x:1e3,y:"calc(100vh - 240px)"}},{bodyCell:n(({column:g,text:C,record:y})=>[g.dataIndex==="paramKey"?(l(),u(f,{key:0},[y.isEdit?(l(),k(v,{key:0,placeholder:"\u8BF7\u8F93\u5165\u53C2\u6570\u540D\u79F0",value:t.docEdit.paramKey,"onUpdate:value":e[0]||(e[0]=_=>t.docEdit.paramKey=_)},null,8,["value"])):(l(),u("span",Q,G(C),1))],64)):b("",!0),g.dataIndex==="paramValue"?(l(),u(f,{key:1},[y.isEdit?(l(),k(v,{key:0,rows:1,placeholder:"\u8BF7\u8F93\u5165\u53C2\u6570\u503C",value:t.docEdit.paramValue,"onUpdate:value":e[1]||(e[1]=_=>t.docEdit.paramValue=_)},null,8,["value"])):(l(),u("span",W,G(C),1))],64)):b("",!0),g.dataIndex==="paramType"?(l(),u(f,{key:2},[y.isEdit?(l(),k(T,{key:0,placeholder:"\u53C2\u6570\u4F4D\u7F6E",value:t.docEdit.paramType,"onUpdate:value":e[2]||(e[2]=_=>t.docEdit.paramType=_),style:{width:"110px"}},{default:n(()=>[d(E,{value:1},{default:n(()=>[X]),_:1}),d(E,{value:2},{default:n(()=>[Y]),_:1}),d(E,{value:3},{default:n(()=>[$]),_:1})]),_:1},8,["value"])):(l(),u(f,{key:1},[C===1?(l(),k(o,{key:0,color:"green"},{default:n(()=>[ee]),_:1})):C===2?(l(),k(o,{key:1,color:"pink"},{default:n(()=>[ae]),_:1})):C===3?(l(),k(o,{key:2,color:"pink"},{default:n(()=>[te]),_:1})):b("",!0)],64))],64)):b("",!0),g.dataIndex==="operation"?(l(),u(f,{key:3},[y.isEdit?(l(),u(f,{key:0},[d(p,{type:"link",onClick:_=>t.cancelEditDoc(y)},{default:n(()=>[oe]),_:2},1032,["onClick"]),d(p,{type:"link",onClick:_=>t.saveEditDoc(y)},{default:n(()=>[ne]),_:2},1032,["onClick"])],64)):(l(),u(f,{key:1},[d(p,{type:"link",onClick:_=>t.editDoc(y)},{default:n(()=>[le]),_:2},1032,["onClick"]),d(r,{title:"\u786E\u5B9A\u8981\u5220\u9664\u5417\uFF1F",onConfirm:_=>t.deleteDoc(y)},{default:n(()=>[d(p,{type:"link",danger:""},{default:n(()=>[ie]),_:1})]),_:2},1032,["onConfirm"])],64))],64)):b("",!0)]),_:1},8,["dataSource","columns","loading","scroll"])],64)}var _e=R(q,[["render",de]]);export{_e as E};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
import"./custom.6a6c45c1.js";import{E as o}from"./EditGlobalParam.67e61140.js";import{_ as r}from"./main.92a9e84b.js";import{r as t,o as e,c as s}from"./vendor.948fa90f.js";const c={components:{EditGlobalParam:o},setup(){return{}}};function m(n,p,l,i,d,_){const a=t("EditGlobalParam");return e(),s(a,{"dynamic-param":{docId:0}})}var G=r(c,[["render",m]]);export{G as default};

View File

@@ -1 +0,0 @@
import{_ as e}from"./main.92a9e84b.js";import{o as t,b as o}from"./vendor.948fa90f.js";const n={name:"SettingView",components:{},data(){return{}},computed:{},mounted(){},methods:{}};function r(a,s,c,m,i,p){return t(),o("div",null," \u5C55\u793A\u914D\u7F6E\u9875\u9762 ")}var _=e(n,[["render",r]]);export{_ as default};

View File

@@ -1 +0,0 @@
import{u as p,y as g,H as f,G as x,o as i,b as l,e as _,F as w,d as L,ax as N,ay as C,t as H,ar as I,r as m,a as v,w as u,c as S,k as b}from"./vendor.948fa90f.js";import{m as A}from"./index.b99389a4.js";import{_ as y}from"./main.92a9e84b.js";const T={props:{heading:{type:Array,default:[]}},setup(r){const s=p();let a=g("100px");f(()=>{window.onresize=()=>{n()},setTimeout(()=>{n()},100)}),x(s.getters.getLeftAsideWidth,()=>{n()});let e=g();const n=()=>{a.value=window.getComputedStyle(e.value,null).width};return{navigationRef:e,navigationWidth:a,headingItemClick:t=>{t.node.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}}}},D={class:"navigation"},B={ref:"navigationRef",style:{display:"inline-block",width:"100%",height:"1px"}},M=["onClick"];function R(r,s,a,e,n,c){return i(),l("div",D,[_("div",B,null,512),_("div",{class:"navigation-heading",style:N({width:e.navigationWidth})},[(i(!0),l(w,null,L(a.heading,t=>(i(),l("div",{class:C("heading-item heading-"+t.level),onClick:o=>e.headingItemClick(t)},H(t.text),11,M))),256))],4)])}var V=y(T,[["render",R]]);const W={components:{Navigation:V},setup(){const r=p(),s=I(()=>r.state.apiDoc);let a=g();x(r.getters.getApiDoc,()=>{setTimeout(()=>{c(".share-instruction")},100)});const e=t=>A.exports.markdownIt.render(t||"");let n=g([]);const c=t=>{if(!document.querySelector(t))return[];let o=document.querySelector(t).querySelectorAll("h1,h2,h3,h4,h5,h6");if(o.length<=0)return[];let d=[];o.forEach(h=>{let k=h.innerHTML.replace(/^\s+/g,"").replace(/\s+$/g,"").replace(/<\/?[^>]+(>|$)/g,"");d.push({node:h,level:parseInt(h.tagName.replace(/[h]/i,""),10),text:k})}),n.value=d};return f(()=>{}),{apiDoc:s,navigationRef:a,navigationList:n,markdownToHtml:e}}},$={key:0},j=["innerHTML"],q={key:1,style:{"text-align":"center"}};function z(r,s,a,e,n,c){const t=m("Navigation"),o=m("a-col"),d=m("a-row");return e.apiDoc.shareInstruction?(i(),l("div",$,[v(d,null,{default:u(()=>[e.navigationList.length>0?(i(),S(o,{key:0,xs:0,sm:4,md:4,lg:6,xl:6},{default:u(()=>[v(t,{ref:"navigationRef",heading:e.navigationList},null,8,["heading"])]),_:1})):b("",!0),v(o,{xs:24,sm:e.navigationList.length>0?20:24,md:e.navigationList.length>0?20:24,lg:e.navigationList.length>0?18:24,xl:e.navigationList.length>0?18:24},{default:u(()=>[_("div",{class:"markdown-body share-instruction",innerHTML:e.markdownToHtml(e.apiDoc.shareInstruction),style:{margin:"0 auto","max-width":"1000px"}},null,8,j)]),_:1},8,["sm","md","lg","xl"])]),_:1})])):(i(),l("div",q,"\u6B22\u8FCE\u8BBF\u95EE\u5F00\u653EAPI\u6587\u6863"))}var P=y(W,[["render",z]]);export{P as default};

View File

@@ -1 +0,0 @@
var x=Object.defineProperty,O=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var b=(r,e,t)=>e in r?x(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y=(r,e)=>{for(var t in e||(e={}))k.call(e,t)&&b(r,t,e[t]);if(L)for(var t of L(e))M.call(e,t)&&b(r,t,e[t]);return r},v=(r,e)=>O(r,E(e));import{_ as R}from"./main.92a9e84b.js";import{H as j,y as T,o as z,b as C,e as D}from"./vendor.948fa90f.js";const w=["get","head","post","put","patch","delete","options","trace"];function W(r){let e={},t={},o={},h=r.paths;return h?(Object.keys(h).forEach(n=>{let s=h[n];for(let a of w){if(!s[a]||!s[a].tags)continue;let p=a.toLowerCase();o[p]=(o[p]||0)+1,o.total=(o.total||0)+1,s[a].tags.forEach(c=>{let i=e[c];i||(i=e[c]={});let l=i[n];l||(l=i[n]={});let f=n+"."+a;l[a]=s[a],l[a].path=f,l[a].url=n,l[a].method=a,t[f]=s[a]})}}),{urlMethodMap:t,tagPathMap:e,methodStatistic:o}):{urlMethodMap:t,tagPathMap:e,methodStatistic:o}}function H(r,e,t,o){let h=[],n=1,s=r.tags||[];return s.length<=0&&Object.keys(e).forEach(a=>s.push({name:a})),s.forEach(a=>{let p=1,c=[],i=e[a.name];!i||(Object.keys(i).forEach(l=>{let f=1,d=i[l];Object.keys(d).forEach(g=>{let m=n+"_"+p+"_"+f,u=d[g];if(!I(l,u,t))return;u.treeId=m;let _=u.summary||u.path;c.push({title:_,key:m,isLeaf:!0,method:u.method,query:v(y({},o),{path:u.url,method:u.method})}),f++}),p++}),c.length>0&&h.push({title:a.name,key:n,children:c}),n++)}),[{key:"main",title:r.info.title||"Swagger\u63A5\u53E3\u6587\u6863",children:h}]}function I(r,e,t){if(!t||!r||(r=r.toLowerCase(),t=t.toLowerCase(),r.indexOf(t)>=0))return!0;let o=e.path+e.method+e.summary+e.description+e.tags;return o&&o.toLowerCase().indexOf(t)>=0}const $=["get","head","post","put","patch","delete","options","trace"];function V(r){let e={},t={},o={},h=r.paths;return h?(Object.keys(h).forEach(n=>{let s=h[n];for(let a of $){if(!s[a]||!s[a].tags)continue;let p=a.toLowerCase();o[p]=(o[p]||0)+1,o.total=(o.total||0)+1,s[a].tags.forEach(c=>{let i=e[c];i||(i=e[c]={});let l=i[n];l||(l=i[n]={});let f=n+"."+a;l[a]=s[a],l[a].path=f,l[a].url=n,l[a].method=a,t[f]=s[a]})}}),{urlMethodMap:t,tagPathMap:e,methodStatistic:o}):{urlMethodMap:t,tagPathMap:e,methodStatistic:o}}function G(r,e,t,o){let h=[],n=1,s=r.tags||[];return s.length<=0&&Object.keys(e).forEach(a=>s.push({name:a})),s.forEach(a=>{let p=1,c=[],i=e[a.name];!i||(Object.keys(i).forEach(l=>{let f=1,d=i[l];Object.keys(d).forEach(g=>{let m=n+"_"+p+"_"+f,u=d[g];if(!A(l,u,t))return;u.treeId=m;let _=u.summary||u.path;c.push({title:_,key:m,isLeaf:!0,method:u.method,query:v(y({},o),{path:u.url,method:u.method})}),f++}),p++}),c.length>0&&h.push({title:a.name,key:n,children:c}),n++)}),[{key:"main",title:r.info.title||"OpenApi\u63A5\u53E3\u6587\u6863",children:h}]}function A(r,e,t){if(!t||!r||(r=r.toLowerCase(),t=t.toLowerCase(),r.indexOf(t)>=0))return!0;let o=e.path+e.method+e.summary+e.description+e.tags;return o&&o.toLowerCase().indexOf(t)>=0}const B={emits:["update:value","change"],setup(r,{emit:e}){j(()=>{n()});let t=T(300),o=T(),h=T();const n=()=>{let s=o.value,a=h.value;s.onmousedown=p=>{let c=p.clientX;return s.style.background="#ccc",a.style.background="#aaa",s.left=s.offsetLeft,document.onmousemove=i=>{let l=i.clientX,f=c-l;(f<0&&t.value<600||f>0&&t.value>300)&&(c=l,t.value-=f,t.value<300&&(t.value=300),e("update:value",t.value),e("change",t.value))},document.onmouseup=()=>{s.style.background="#fafafa",a.style.background="#ccc",document.onmousemove=null,document.onmouseup=null},!1}};return{leftAsideWidth:t,leftResizeRef:o,leftResizeBarRef:h}}},P={ref:"leftResizeRef",class:"left-resize"},U={ref:"leftResizeBarRef"};function S(r,e,t,o,h,n){return z(),C("div",P,[D("i",U,"...",512)],512)}var J=R(B,[["render",S],["__scopeId","data-v-33303c20"]]),K="assets/api-logo.952f0c92.png";export{J as L,K as _,W as a,V as b,G as c,H as g};

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

View File

@@ -1 +0,0 @@
import{B as r}from"./vendor.948fa90f.js";var g={log(o,l,s){console.log(o+"-\u9047\u5230\u672A\u5904\u7406\u7684\u7C7B\u578B\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u4EBA\u5458\u4FEE\u6539\uFF1A"+l,s)},logMessage(o,l,s){console.log(o+"-\u9047\u5230\u672A\u5904\u7406\u7684\u7C7B\u578B\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u4EBA\u5458\u4FEE\u6539\uFF1A"+l,s),r.error(o+"-\u9047\u5230\u672A\u5904\u7406\u7684\u7C7B\u578B\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u4EBA\u5458\u4FEE\u6539\uFF1A"+l)}};export{g as l};

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

File diff suppressed because one or more lines are too long

View File

@@ -5,9 +5,9 @@
<link rel="icon" href="api-logo.png" /> <link rel="icon" href="api-logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>API文档管理</title> <title>API文档管理</title>
<script type="module" crossorigin src="assets/main.92a9e84b.js"></script> <script type="module" crossorigin src="assets/main.8a6f02ce.js"></script>
<link rel="modulepreload" href="assets/vendor.948fa90f.js"> <link rel="modulepreload" href="assets/vendor.af29ba15.js">
<link rel="stylesheet" href="assets/style.a6d9edcc.css"> <link rel="stylesheet" href="assets/style.4953518a.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@@ -138,7 +138,7 @@ export default {
/** /**
* 解析请求返回的结果集 * 解析请求返回的结果集
* @param responses swagger.parameters * @param responses swagger.parameters
* @param definitionsDataMap 解析的path里对应的数据map{url + "." + method: swagger.paths.post} * @param openApiComponents 解析的path里对应的数据map{url + "." + method: swagger.paths.post}
* @returns [] 参数列表:[{ * @returns [] 参数列表:[{
* code: '', * code: '',
* type: '', * type: '',
@@ -147,26 +147,35 @@ export default {
* schemas: [], * schemas: [],
* }] * }]
*/ */
getResponseParamList(responses, definitionsDataMap) { getResponseParamList(responses, openApiComponents) {
let responsesList = []; let responsesList = [];
let indexKey = 1; let indexKey = 1;
Object.keys(responses).forEach(code => { Object.keys(responses).forEach(code => {
let codeResponses = responses[code]; let codeResponses = responses[code];
let type = undefined; let content = codeResponses.content;
let children = undefined; let contentList = [];
if (this.isSchemaRef(codeResponses.schema)) { let resIndexKey = 1;
type = this.getSchemaRef(codeResponses.schema); Object.keys(content).forEach(resType => {
children = this.getParamDefinitions(type, definitionsDataMap, indexKey, {}, 0); let contentValue = content[resType];
} let keySub = indexKey + '_' + resIndexKey;
// 通用解析方法
let analysis = this.analysisParamObj(contentValue, openApiComponents, keySub);
contentList.push({
mediaType: resType,
key: keySub,
schemas: analysis.children,
});
resIndexKey++;
});
responsesList.push({ responsesList.push({
code: code, code: code,
type: type,
key: indexKey, key: indexKey,
desc: codeResponses.description, desc: codeResponses.description,
schemas: children, childrens: contentList,
}); });
indexKey++; indexKey++;
}); });
console.log(responsesList);
return responsesList; return responsesList;
}, },
/** /**
@@ -183,14 +192,14 @@ export default {
* @returns {string} * @returns {string}
*/ */
getSchemaRef(schema) { getSchemaRef(schema) {
if (schema['$ref'] && schema['$ref'].indexOf('#/definitions/') === 0) return schema['$ref'].replace('#/definitions/', ''); if (schema['$ref'] && schema['$ref'].indexOf('#/components/schemas/') === 0) return schema['$ref'].replace('#/components/schemas/', '');
logUtil.logMessage('9467', '', schema); logUtil.logMessage('9467', '', schema);
return ''; return '';
}, },
/** /**
* 获取swagger.definitions里的对象信息 * 获取swagger.definitions里的对象信息
* @param ref 对象名 * @param ref 对象名
* @param definitionsDataMap 解析的path里对应的数据map{url + "." + method: swagger.paths.post} * @param openApiComponents 解析的path里对应的数据map{url + "." + method: swagger.paths.post}
* @param indexKey 层级key * @param indexKey 层级key
* @param parentRef 父级已用过的ref防止无限递归 * @param parentRef 父级已用过的ref防止无限递归
* @param deep 层级深度大于10层则不再解析防止层级太深或无线递归 * @param deep 层级深度大于10层则不再解析防止层级太深或无线递归
@@ -209,8 +218,9 @@ export default {
* } * }
* } * }
*/ */
getParamDefinitions(ref, definitionsDataMap, indexKey, parentRef, deep) { getParamDefinitions(ref, openApiComponents, indexKey, parentRef, deep) {
let definition = definitionsDataMap[ref]; let componentSchemas = openApiComponents.schemas || {};
let definition = componentSchemas[ref];
// 层级大于5层 或者 没有类型定义 // 层级大于5层 或者 没有类型定义
if (deep >= 10 || !definition) { if (deep >= 10 || !definition) {
return undefined; return undefined;
@@ -221,79 +231,20 @@ export default {
return undefined; return undefined;
} }
let paramList = []; let paramList = [];
let type = definition.type;
let properties = definition.properties; let properties = definition.properties;
let indexSub = 1; let indexSub = 1;
if (type === 'object' && properties) { if (properties) {
let currentLevelTypes = {}; let currentLevelTypes = {};
Object.keys(properties).forEach(key => { Object.keys(properties).forEach(key => {
let parameter = properties[key]; let parameter = properties[key];
let type = parameter.type; let type = parameter.type;
let format = parameter.format;
let description = parameter.description || '';
let example = parameter['example'] || parameter['x-example'];
let subType = undefined;
let additional = undefined;
let enums = undefined;
let keySub = indexKey + '_' + indexSub;
let children = undefined;
// 把当前层级用过的类型清除,防止多个同类型在一层,后面的不能解析 // 把当前层级用过的类型清除,防止多个同类型在一层,后面的不能解析
Object.keys(currentLevelTypes).forEach(currentLevelType => { Object.keys(currentLevelTypes).forEach(currentLevelType => {
parentRef[currentLevelType] = undefined; parentRef[currentLevelType] = undefined;
}); });
if (type === 'array') { let child = this.analysisParamObj(parameter);
// 解析parameter.items {$ref: "#/definitions/Model"} child.name = key;
if (this.isSchemaRef(parameter.items)) { paramList.push(child);
subType = this.getSchemaRef(parameter.items);
children = this.getParamDefinitions(subType, definitionsDataMap, keySub, parentRef, deep + 1);
} else if (parameter.items && parameter.items.type) {
subType = parameter.items.type;
} else {
logUtil.logMessage('004', type, parameter);
}
} else if (type === 'object') {
if (parameter.additionalProperties) {
additional = {};
children = this.getAdditionalProperties(parameter.additionalProperties, additional, definitionsDataMap, keySub, parentRef, deep + 1);
format = additional.type;
} else {
logUtil.log('0041', type, parameter);
}
} else if (!type) {
if (this.isSchemaRef(parameter)) {
type = this.getSchemaRef(parameter);
children = this.getParamDefinitions(type, definitionsDataMap, keySub, parentRef, deep + 1);
} else {
logUtil.logMessage('005', type, parameter);
}
} else {
if (notNeedHandleTypeArr.indexOf(type) >= 0) {
// 无需特殊处理的类型
} else {
logUtil.logMessage('006', type, parameter);
}
}
if (example) {
description = description ? (description + '') : '';
description += '例:' + example;
}
if (parameter.items && parameter.items.enum && parameter.items.enum.length > 0) {
enums = parameter.items.enum;
description = description || '枚举类型';
description += ',可选值:' + parameter.items.enum.join('、');
}
paramList.push({
type: type,
name: key,
key: keySub,
subType: subType,
format: format,
description: description,
enum: enums,
additional: additional,
example: example,
children: children,
});
indexSub++; indexSub++;
currentLevelTypes[type] = 1; currentLevelTypes[type] = 1;
}); });
@@ -304,7 +255,7 @@ export default {
* parameter.schema.additionalProperties 类型的参数值处理 * parameter.schema.additionalProperties 类型的参数值处理
* @param additionalProperties * @param additionalProperties
* @param additional * @param additional
* @param definitionsDataMap * @param openApiComponents
* @param keySub * @param keySub
* @param parentRef * @param parentRef
* @param deep * @param deep
@@ -315,20 +266,20 @@ export default {
* |{children: (undefined|{type: "", name: "", key: "", subType: "", format: "", description: "", enum: "", additional: "", example: "", children: *[]}), type: string} * |{children: (undefined|{type: "", name: "", key: "", subType: "", format: "", description: "", enum: "", additional: "", example: "", children: *[]}), type: string}
* } * }
*/ */
getAdditionalProperties(additionalProperties, additional, definitionsDataMap, keySub, parentRef, deep) { getAdditionalProperties(additionalProperties, additional, openApiComponents, keySub, parentRef, deep) {
if (this.isSchemaRef(additionalProperties)) { if (this.isSchemaRef(additionalProperties)) {
additional.type = this.getSchemaRef(additionalProperties); additional.type = this.getSchemaRef(additionalProperties);
additional.children = this.getParamDefinitions(additional.type, definitionsDataMap, keySub, parentRef, deep + 1); additional.children = this.getParamDefinitions(additional.type, openApiComponents, keySub, parentRef, deep + 1);
return additional.additional; return additional.additional;
} else if (additionalProperties.additionalProperties) { } else if (additionalProperties.additionalProperties) {
additional.type = additionalProperties.type; additional.type = additionalProperties.type;
additional.additional = {}; additional.additional = {};
return this.getAdditionalProperties(additionalProperties.additionalProperties, additional.additional, definitionsDataMap, keySub, parentRef, deep + 1); return this.getAdditionalProperties(additionalProperties.additionalProperties, additional.additional, openApiComponents, keySub, parentRef, deep + 1);
} else if (additionalProperties.type === 'array') { } else if (additionalProperties.type === 'array') {
additional.type = additionalProperties.type; additional.type = additionalProperties.type;
if (this.isSchemaRef(additionalProperties.items)) { if (this.isSchemaRef(additionalProperties.items)) {
let subType = this.getSchemaRef(additionalProperties.items); let subType = this.getSchemaRef(additionalProperties.items);
let children = this.getParamDefinitions(subType, definitionsDataMap, keySub, parentRef, deep + 1); let children = this.getParamDefinitions(subType, openApiComponents, keySub, parentRef, deep + 1);
additional.additional = { additional.additional = {
type: subType, type: subType,
children: children children: children
@@ -347,5 +298,130 @@ export default {
} }
return undefined; return undefined;
}, },
analysisParamObj(parameter, openApiComponents, indexKey) {
let description = parameter.description || '';
let type = parameter.type;
let format = parameter.format;
let example = parameter['x-example'];
let subType = undefined;
let children = undefined;
let additional = undefined;
let enums = undefined;
if (type === 'array') {
// 解析parameter.items.$ref 或 parameter.items.$ref {$ref: "#/definitions/Model"}
// 解析parameter.items.type {type: 'file'}
if (this.isSchemaRef(parameter.items)) {
subType = this.getSchemaRef(parameter.items);
children = this.getParamDefinitions(subType, openApiComponents, indexKey, {}, 0);
} else if (parameter.schema) {
if (this.isSchemaRef(parameter.schema.items)) {
subType = this.getSchemaRef(parameter.schema.items);
children = this.getParamDefinitions(subType, openApiComponents, indexKey, {}, 0);
} else if (parameter.schema.type) {
subType = parameter.schema.type;
}
} else if (parameter.items && parameter.items.type) {
subType = parameter.items.type;
} else if (parameter.items && parameter.items.properties) {
children = [];
let proIndex = 1;
let properties = parameter.items.properties;
Object.keys(properties).forEach(key => {
let parameter = properties[key];
let subKey = indexKey + '_' + proIndex;
let child = this.analysisParamObj(parameter, openApiComponents, subKey);
child.name = key;
children.push(child);
proIndex++;
});
} else {
logUtil.logMessage('001', type, parameter);
}
} else if (!type) {
if (parameter.schema) {
if (this.isSchemaRef(parameter.schema)) {
// 解析parameter.schema {$ref: "#/definitions/Model"}
type = this.getSchemaRef(parameter.schema);
children = this.getParamDefinitions(type, openApiComponents, indexKey, {}, 0);
} else if (parameter.schema.type) {
type = parameter.schema.type;
if (parameter.schema.additionalProperties) {
additional = {};
children = this.getAdditionalProperties(parameter.schema.additionalProperties, additional, openApiComponents, indexKey, {}, 0);
format = additional.type;
} else if (parameter.schema.items) {
if (this.isSchemaRef(parameter.schema.items)) {
subType = this.getSchemaRef(parameter.schema.items);
children = this.getParamDefinitions(subType, openApiComponents, indexKey, {}, 0);
} else if (parameter.schema.items.type) {
subType = parameter.schema.items.type;
} else {
logUtil.log('0014', type, parameter);
}
} else {
logUtil.log('0011', type, parameter);
}
} else {
logUtil.logMessage('0013', type, parameter);
}
} else if (parameter.items && parameter.items.type) {
// 解析parameter.items {type: "object", $ref: "#/definitions/Model"}
type = parameter.items.type;
if (parameter.items.additionalProperties) {
additional = {};
children = this.getAdditionalProperties(parameter.items.additionalProperties, additional, openApiComponents, indexKey, {}, 0);
format = additional.type;
} else {
logUtil.logMessage('0012', type, parameter);
}
} else if (parameter.properties) {
children = [];
let proIndex = 1;
let properties = parameter.properties;
Object.keys(properties).forEach(key => {
let parameter = properties[key];
let subKey = indexKey + '_' + proIndex;
let child = this.analysisParamObj(parameter, openApiComponents, subKey);
child.name = key;
children.push(child);
proIndex++;
});
} else {
logUtil.logMessage('002', type, parameter);
}
} else {
if (notNeedHandleTypeArr.indexOf(type) >= 0) {
// 无需特殊处理的类型
} else {
logUtil.logMessage('003', type, parameter);
}
}
// 丰富说明内容
if (example) {
description = description ? (description + '') : '';
description += '例:' + example;
}
if (parameter.items && parameter.items.enum && parameter.items.enum.length > 0) {
enums = parameter.items.enum;
description = description || '枚举类型';
description += ',可选值:' + parameter.items.enum.join('、');
}
console.log("xxx",parameter)
return {
type: type,
key: indexKey,
in: parameter.in,
name: parameter.name,
subType: subType,
required: parameter.required ? '是' : '否',
format: format,
enum: parameter.enum,
example: example,
collectionFormat: parameter.collectionFormat,// 枚举多选时=multi
description: description,
additional: additional,
children: children,
};
}
} }

View File

@@ -14,7 +14,7 @@
<a-tag color="purple" v-else-if="method === 'options'">options</a-tag> <a-tag color="purple" v-else-if="method === 'options'">options</a-tag>
<a-tag color="purple" v-else-if="method === 'trace'">trace</a-tag> <a-tag color="purple" v-else-if="method === 'trace'">trace</a-tag>
</template> </template>
<span style="margin: 0 6px 0 3px;">{{title}}</span> <span style="margin: 0 6px 0 3px;word-break: break-all;">{{title}}</span>
<a-badge v-if="children" :count="children.length" :number-style="{backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset'}"/> <a-badge v-if="children" :count="children.length" :number-style="{backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset'}"/>
</template> </template>
</a-directory-tree> </a-directory-tree>

View File

@@ -30,7 +30,7 @@ export default createStore({
// openApi原始文档 // openApi原始文档
openApiDoc: {}, openApiDoc: {},
// openApi原始definitions // openApi原始definitions
openApiDefinitions: {}, openApiComponents: {},
// url对应的map信息 {'url + "." + method': {swagger.paths.url.method对象信息}} // url对应的map信息 {'url + "." + method': {swagger.paths.url.method对象信息}}
openApiUrlMethodMap: {}, openApiUrlMethodMap: {},
// 方法统计{post: 10, total: 20} // 方法统计{post: 10, total: 20}
@@ -94,7 +94,7 @@ export default createStore({
// openApi // openApi
setOpenApiDoc(state, openApiDoc) { setOpenApiDoc(state, openApiDoc) {
state.openApiDoc = openApiDoc; state.openApiDoc = openApiDoc;
state.openApiDefinitions = openApiDoc.definitions || {}; state.openApiComponents = openApiDoc.components || {};
}, },
setOpenApiUrlMethodMap(state, openApiUrlMethodMap) { setOpenApiUrlMethodMap(state, openApiUrlMethodMap) {
state.openApiUrlMethodMap = openApiUrlMethodMap; state.openApiUrlMethodMap = openApiUrlMethodMap;

View File

@@ -9,7 +9,9 @@
<a-radio :value="2">Swagger JSON</a-radio> <a-radio :value="2">Swagger JSON</a-radio>
<a-radio :value="3">OpenApi URL</a-radio> <a-radio :value="3">OpenApi URL</a-radio>
<a-radio :value="4">OpenApi JSON</a-radio> <a-radio :value="4">OpenApi JSON</a-radio>
<a-radio :value="5">自建API</a-radio> <a-tooltip title="即将上线,敬请期待">
<a-radio :value="5" disabled>自建API</a-radio>
</a-tooltip>
</a-radio-group> </a-radio-group>
</a-form-item> </a-form-item>
<a-form-item label="文档地址" required name="docUrl" v-if="docEdit.docType === 1"> <a-form-item label="文档地址" required name="docUrl" v-if="docEdit.docType === 1">

View File

@@ -87,9 +87,9 @@
produces: produces, produces: produces,
}; };
// 解析请求参数 // 解析请求参数
let definitionsDataMap = store.state.openApiDefinitions; let openApiComponents = store.state.openApiComponents;
requestParamList.value = openApiAnalysis.getRequestParamList(docInfo.parameters, definitionsDataMap); requestParamList.value = openApiAnalysis.getRequestParamList(docInfo.parameters, openApiComponents);
responseParamList.value = openApiAnalysis.getResponseParamList(docInfo.responses, definitionsDataMap); responseParamList.value = openApiAnalysis.getResponseParamList(docInfo.responses, openApiComponents);
} }
onMounted(() => { onMounted(() => {
initLoadDocument(); initLoadDocument();

View File

@@ -42,8 +42,8 @@
</template> </template>
</template> </template>
<template #expandedRowRender="{ record }"> <template #expandedRowRender="{ record }">
<template v-if="record.schemas"> <template v-if="record.childrens">
<a-table :dataSource="record.schemas" :columns="responseParamListColumns" size="small" :pagination="false"> <a-table :dataSource="record.childrens" :columns="responseMediaTypeColumns" size="small" :pagination="false">
<template #bodyCell="{ column, text, record }"> <template #bodyCell="{ column, text, record }">
<template v-if="column.dataIndex === 'type'"> <template v-if="column.dataIndex === 'type'">
{{text}} {{text}}
@@ -51,9 +51,23 @@
<template v-if="record.format">({{record.format}})</template> <template v-if="record.format">({{record.format}})</template>
</template> </template>
</template> </template>
<template #expandedRowRender="{ record }">
<template v-if="record.schemas">
<a-table :dataSource="record.schemas" :columns="responseParamListColumns" size="small" :pagination="false">
<template #bodyCell="{ column, text, record }">
<template v-if="column.dataIndex === 'type'">
{{text}}
<template v-if="record.subType">[{{record.subType}}]</template>
<template v-if="record.format">({{record.format}})</template>
</template>
</template>
</a-table>
</template>
<div v-else style="text-align: center;padding: 10px 0;">无结果说明</div>
</template>
</a-table> </a-table>
</template> </template>
<div v-else style="text-align: center;padding: 10px 0;">参数说明</div> <div v-else style="text-align: center;padding: 10px 0;">结果说明</div>
</template> </template>
</a-table> </a-table>
</a-form-item> </a-form-item>
@@ -98,6 +112,9 @@
{title: '类型', dataIndex: 'type', width: 250}, {title: '类型', dataIndex: 'type', width: 250},
{title: '说明', dataIndex: 'desc'}, {title: '说明', dataIndex: 'desc'},
], ],
responseMediaTypeColumns: [
{title: '媒体类型', dataIndex: 'mediaType'},
],
responseParamListColumns: [ responseParamListColumns: [
{title: '参数名', dataIndex: 'name', width: 250}, {title: '参数名', dataIndex: 'name', width: 250},
{title: '类型', dataIndex: 'type', width: 250}, {title: '类型', dataIndex: 'type', width: 250},

View File

@@ -79,7 +79,7 @@
produces: produces, produces: produces,
}; };
// 解析请求参数 // 解析请求参数
let definitionsDataMap = store.state.openApiDefinitions; let definitionsDataMap = store.state.openApiComponents;
requestParamList.value = openApiAnalysis.getRequestParamList(docInfo.parameters, definitionsDataMap); requestParamList.value = openApiAnalysis.getRequestParamList(docInfo.parameters, definitionsDataMap);
responseParamList.value = openApiAnalysis.getResponseParamList(docInfo.responses, definitionsDataMap); responseParamList.value = openApiAnalysis.getResponseParamList(docInfo.responses, definitionsDataMap);
} }