├── .gitignore ├── .prettierrc ├── .travis.yml ├── LICENSE ├── README.md ├── build.sh ├── config ├── font-clip.html ├── generatePom.js └── pom.template.xml ├── dist ├── swagger-ui.html └── webjars │ └── swagger-document-ui │ ├── css │ ├── app.css │ ├── app.css.gz │ ├── chunk-vendors.css │ ├── chunk-vendors.css.gz │ ├── entity-view.css │ └── entity-view.css.gz │ ├── favicon.ico │ ├── favicon.ico.gz │ ├── img │ ├── ionicons.svg │ └── ionicons.svg.gz │ └── js │ ├── app.js │ ├── app.js.gz │ ├── chunk-vendors.js │ ├── chunk-vendors.js.gz │ ├── entity-view.js │ └── entity-view.js.gz ├── docs ├── demo1.png ├── demo2.png ├── demo3.png ├── demo4.png ├── postman1.png └── postman2.png ├── package.json ├── public ├── index.html └── webjars │ └── swagger-document-ui │ └── favicon.ico ├── src ├── App.vue ├── components │ ├── CopiedTag.vue │ ├── ExportPostman.vue │ ├── MethodTag.vue │ ├── SearchInput.vue │ └── SwaggerResources.vue ├── iview-clip.js ├── main.js ├── router.js ├── utils │ ├── $.js │ ├── api.js │ ├── postman.js │ └── swagger.js └── views │ ├── Home.vue │ ├── app-layout │ ├── HeaderContent.vue │ └── SiderContent.vue │ └── entity-view │ ├── EntityView.vue │ ├── EntityViewApiInfo.vue │ ├── EntityViewBean.vue │ ├── EntityViewParam.vue │ ├── EntityViewResponse.vue │ ├── copiedTagRender.js │ └── index.js ├── tests ├── swagger-resources.json └── unit │ ├── .eslintrc.js │ └── utils │ ├── postman.spec.js │ ├── swagger.json │ └── swagger.spec.js ├── vue.config.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /target 4 | /pom.xml 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "printWidth": 120, 4 | "singleQuote": true 5 | } 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '11.14.0' 4 | before_script: 5 | - yarn global add @vue/cli 6 | - yarn global add font-spider 7 | install: 8 | - yarn 9 | 10 | script: 11 | - yarn build 12 | - yarn test:unit 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 2 | [![Build Status](https://travis-ci.org/cn-src/swagger-document-ui.svg?branch=dev)](https://travis-ci.org/cn-src/swagger-document-ui) 3 | [![Maven Central](https://img.shields.io/maven-central/v/cn.javaer.springfox/swagger-document-ui.svg)](https://search.maven.org/search?q=g:cn.javaer.springfox%20AND%20a:swagger-document-ui&core=gav) 4 | [![star](https://gitee.com/cn-src/swagger-document-ui/badge/star.svg?theme=dark)](https://gitee.com/cn-src/swagger-document-ui/stargazers) 5 | 6 | # Swagger 规范接口的 UI 7 | 8 | --- 9 | 10 | - 主要体现文档的可读性功能,给接口调用者提供接口文档,省去文档编写。 11 | - 此项目没有类似官方的在线测试/调试功能,建议使用 Postman,Postman 默认支持 swagger 规范的接口导入,但文件夹结构不与文档一致,所以定制了 Postman 导出功能。 12 | - [在线样例](http://cn-src.gitee.io/swagger-document-ui/swagger-ui.html) 13 | - [更新日志](https://github.com/cn-src/swagger-document-ui/releases) 14 | 15 | # 使用方式 16 | 17 | ## springfox 框架集成 18 | 19 | - [springfox 官方文档](http://springfox.github.io/springfox/docs/current/) 20 | 21 | 1. 移除官方 UI 依赖 22 | 23 | ```xml 24 | 25 | io.springfox 26 | springfox-swagger-ui 27 | ${springfox.version} 28 | 29 | ``` 30 | 31 | 2. 添加 swagger-document-ui 依赖 32 | 33 | ```xml 34 | 35 | cn.javaer.springfox 36 | swagger-document-ui 37 | 1.0.2 38 | 39 | ``` 40 | 41 | ## Spring Boot 集成 42 | 43 | 与 Spring Boot 集成使用是最简单的方式,推荐使用 [程序猿 DD/spring-boot-starter-swagger](https://gitee.com/didispace/spring-boot-starter-swagger) 44 | 提供的集成方式,然后你需要: 45 | 46 | 1. 排除自带 UI 依赖 47 | 48 | ```xml 49 | 50 | com.spring4all 51 | swagger-spring-boot-starter 52 | ${swagger-spring-boot-starter.version} 53 | 54 | 55 | 56 | springfox-swagger-ui 57 | io.springfox 58 | 59 | 60 | 61 | ``` 62 | 63 | 2. 添加 swagger-document-ui 依赖 64 | 65 | ```xml 66 | 67 | cn.javaer.springfox 68 | swagger-document-ui 69 | 1.0.2 70 | 71 | ``` 72 | 73 | ## 静态资源部署 74 | 75 | > 此项目最终是生成纯静态资源,只要将 dist 目录里的静态文件部署到 web 服务器下即可使用,但前提是:你的项目中使用了 swagger 规范的 API 信息接口。 76 | 77 | 1. 其会请求 `/swagger-resources` (springfox 框架默认地址) 和 `/swagger-resources.json` (本项目新增地址) 拿到 API 信息接口地址。 78 | 2. 请求 `swagger-resources` 中配置的 `url`(优先) 或者 `location`(兼容旧版不提供 url 字段) 其应当返回 swagger 规范的 API 信息即可使用。 79 | 3. 可参考在线样例的部署方式,分支:[online-demo](https://gitee.com/cn-src/swagger-document-ui/tree/online-demo/) 80 | 81 | # 效果预览 82 | 83 | ## 右侧文档锚点导航 84 | 85 | ![](docs/demo1.png) 86 | 87 | ## 分组选择 API 88 | 89 | ![](docs/demo2.png) 90 | 91 | ## 模糊搜索 92 | 93 | - 支持中文,拼音,英文 94 | - 可搜索 API 名称,分类名称,url 路径 95 | 96 | ![](docs/demo3.png) 97 | 98 | ## 导出 Postman 99 | 100 | ![](docs/demo4.png) 101 | ![](docs/postman1.png) 102 | ![](docs/postman2.png) 103 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | yarn run font-spider config/font-clip.html 3 | yarn run build 4 | node config/generatePom.js 5 | mvn clean package 6 | -------------------------------------------------------------------------------- /config/font-clip.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | -------------------------------------------------------------------------------- /config/generatePom.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | const pg = JSON.parse(fs.readFileSync(__dirname + '/../package.json', { encoding: 'UTF-8' })); 4 | let data = fs.readFileSync(__dirname + '/pom.template.xml', { encoding: 'UTF-8' }); 5 | 6 | data = data.replace(/{{artifactId}}/g, pg.name); 7 | data = data.replace(/{{version}}/g, pg.version); 8 | 9 | const contributor = pg.contributors[0].split(' '); 10 | data = data.replace(/{{developer-id}}/g, contributor[0]); 11 | data = data.replace(/{{developer-name}}/g, contributor[0]); 12 | data = data.replace(/{{developer-email}}/g, contributor[1].substring(1, contributor[1].length - 1)); 13 | 14 | data = data.replace(/{{license.name}}/g, pg.license); 15 | data = data.replace(/{{repo-git.url}}/g, pg.repository); 16 | data = data.replace(/{{repo.url}}/g, pg.repository.substring(0, pg.repository.length - 4)); 17 | 18 | console.log("[Generate]: pom.xml"); 19 | fs.writeFileSync(__dirname + '/../pom.xml', data); 20 | 21 | -------------------------------------------------------------------------------- /config/pom.template.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | cn.javaer.springfox 7 | {{artifactId}} 8 | jar 9 | {{version}} 10 | Swagger Document UI 11 | WebJar for Swagger Document UI 12 | https://github.com/cn-src/swagger-document-ui 13 | 14 | 15 | UTF-8 16 | ${project.build.outputDirectory}/META-INF/resources/ 17 | 18 | 19 | 20 | 21 | {{developer-id}} 22 | {{developer-name}} 23 | {{developer-email}} 24 | 25 | 26 | 27 | 28 | 29 | {{license.name}} 30 | {{repo.url}} 31 | repo 32 | 33 | 34 | 35 | 36 | {{repo.url}} 37 | scm:git:{{repo-git.url}} 38 | scm:git:{{repo-git.url}} 39 | v{{version}} 40 | 41 | 42 | 43 | ${project.build.directory}/cpSrc 44 | 45 | 46 | maven-antrun-plugin 47 | 1.8 48 | 49 | 50 | process-resources 51 | 52 | run 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.sonatype.plugins 72 | nexus-staging-maven-plugin 73 | 1.6.8 74 | true 75 | 76 | ossrh 77 | https://oss.sonatype.org/ 78 | true 79 | 80 | 81 | 82 | maven-source-plugin 83 | 3.0.1 84 | 85 | true 86 | 87 | 88 | 89 | attach-sources 90 | 91 | jar-no-fork 92 | 93 | 94 | 95 | 96 | 97 | org.apache.maven.plugins 98 | maven-gpg-plugin 99 | 1.6 100 | 101 | 102 | sign-artifacts 103 | verify 104 | 105 | sign 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /dist/swagger-ui.html: -------------------------------------------------------------------------------- 1 | API 文档
-------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/css/app.css: -------------------------------------------------------------------------------- 1 | .http-method-tag[data-v-fd3409d6]{font-size:10px;font-weight:700;width:50px;display:inline-block;text-align:right;padding-right:5px}.ivu-modal .ivu-icon-ios-close{top:-13px!important}html{overflow-y:hidden}.ivu-table-overflowX{overflow-x:hidden!important}.ivu-menu-item{padding-left:20px!important} -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/css/app.css.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/css/app.css.gz -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/css/chunk-vendors.css.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/css/chunk-vendors.css.gz -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/css/entity-view.css: -------------------------------------------------------------------------------- 1 | #doc-content{height:75vh;overflow-y:auto;padding-bottom:100px}@media (min-width:801px){#doc-content{padding-right:140px}}#doc-content li{margin:5px 0}#doc-content li h2,#doc-content li h3{margin-top:30px}.anchor-auto{top:100px;right:20px;position:fixed;width:120px}@media (max-width:800px){.anchor-auto{display:none}}@media (max-width:800px){.divider-auto{padding-right:15px}}@media (min-width:801px){.divider-auto{padding-right:155px}}.no-border .ivu-table-wrapper,.no-border .ivu-table-wrapper td{border:0}.no-border .ivu-table:after,.no-border .ivu-table:before{width:0} -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/css/entity-view.css.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/css/entity-view.css.gz -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/favicon.ico -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/favicon.ico.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/favicon.ico.gz -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/img/ionicons.svg.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/img/ionicons.svg.gz -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/js/app.js: -------------------------------------------------------------------------------- 1 | (function(e){function t(t){for(var r,a,s=t[0],c=t[1],u=t[2],l=0,p=[];l0&&n.request.header.push({key:"Content-Type",value:e.consumes[0]}),a.item.push(n)})}),JSON.stringify(n)}var Z={exportJson:X},ee={name:"ExportPostman",data:function(){return{show:!1,exportDownloadDisabled:!1,formData:{exportType:"copy"}}},methods:{onOk:function(){var e=this;if("copy"===this.$data.formData.exportType)new W.a("#exportOkBtn",{text:function(){return Z.exportJson(e.$root.currentSwaggerJson,{basePath:e.formData.basePath})}}),this.$Message.success("复制成功"),this.$data.show=!1;else if("download"===this.$data.formData.exportType){var t=Z.exportJson(e.$root.currentSwaggerJson,{basePath:e.formData.basePath}),n=new Blob([t],{type:"text/plain;charset=utf-8"});z.a.saveAs(n,e.$root.currentSwaggerJson.info.title+".json"),this.$Message.success("下载成功"),this.$data.show=!1}}},created:function(){this.$data.formData.basePath=this.$root.baseURL;try{this.$data.exportDownloadDisabled=!new Blob}catch(e){}}},te=ee,ne=(n("15d2"),Object(w["a"])(te,H,K,!1,null,null,null)),re=ne.exports,ae={name:"HeaderContent",components:{SearchInput:M,SwaggerResources:F,ExportPostman:re},methods:{headerAction:function(e){"swaggerResources"===e?this.$refs.swaggerResources.show=!0:"exportPostman"===e&&(this.$refs.exportPostman.show=!0)},collapsedSider:function(){this.$root.isCollapsed=!this.$root.isCollapsed}},computed:{infoTitle:function(){var e=this.$root.currentSwaggerJson;return e&&e.info&&e.info.title||""}}},oe=ae,ie=Object(w["a"])(oe,i,s,!1,null,null,null),se=ie.exports,ce=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("Menu",{ref:"navMenu",attrs:{"open-names":e.activeSubmenu,"active-name":e.activeMenuItem,theme:"dark",width:"auto",accordion:""},on:{"on-select":e.menuItemAction}},[n("MenuItem",{attrs:{name:"Home"}},[n("Icon",{attrs:{type:"md-home"}}),e._v("首页")],1),e._l(e.swaggerCollection,function(t,r,a){return n("Submenu",{key:a,attrs:{name:r}},[n("template",{slot:"title"},[n("Icon",{attrs:{type:"ios-pricetags"}}),e._v(e._s(r))],1),e._l(t,function(t){return[n("MenuItem",{key:t.id,attrs:{name:t.id}},[n("MethodTag",{attrs:{method:t.method}}),t.deprecated?[n("span",{staticStyle:{color:"#787a7b"}},[n("del",[e._v(e._s(t.name))])])]:[e._v(e._s(t.name))]],2)]})],2)})],2)},ue=[],le={name:"SiderContent",components:{MethodTag:S},methods:{menuItemAction:function(e){"Home"===e?this.$router.push("/"):this.$router.push("/entity/".concat(e))}},computed:{swaggerCollection:function(){var e=this.$root.currentSwaggerJson;return e&&e.collection||{}},activeSubmenu:function(){return this.$root.activeMenu.submenu},activeMenuItem:function(){return this.$root.activeMenu.menuItem}},watch:{"$root.activeMenu.submenu":function(){var e=this;this.$nextTick(function(){e.$refs.navMenu.updateOpened()})}}},pe=le,fe=Object(w["a"])(pe,ce,ue,!1,null,null,null),me=fe.exports,de={name:"App",components:{HeaderContent:se,SiderContent:me},data:function(){return{isCollapsed:!1}},watch:{"$root.isCollapsed":function(){this.$refs.side1.toggleCollapse()}}},he=de,ge=(n("7c55"),Object(w["a"])(he,a,o,!1,null,null,null)),ve=ge.exports,ye=n("8c4f"),we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticStyle:{height:"85vh",overflow:"auto",padding:"24px 24px 50px"}},[n("Divider",[e._v(e._s(e.apiTitle))]),n("Table",{attrs:{columns:e.apiInfoColumns,data:e.apiInfoItems,"show-header":!1,border:""}})],1)},be=[],Se={name:"Home",data:function(){return{apiInfoColumns:[{title:"",key:"k1",width:110,align:"right"},{title:"",key:"k2",render:ke}],classicQuote:""}},computed:{apiTitle:function(){return this.$root.currentSwaggerJson&&this.$root.currentSwaggerJson.info?this.$root.currentSwaggerJson.info.title:""},apiInfoItems:function(){if(!this.$root.currentSwaggerJson||!this.$root.currentSwaggerJson.info)return[];var e=this.$root.currentSwaggerJson.info;return[{k1:"描述:",k2:e.description},{k1:"版本:",k2:e.version},{k1:"许可证:",k2:e.license},{k1:"服务条款:",k2:e.termsOfService},{k1:"开发人员:",k2:e.contact.email},{k1:"host:",k2:e.host},{k1:"basePath:",k2:e.basePath}]}}};function ke(e,t){if("许可证:"===t.row.k1){var n=t.row.k2;return e("a",{attrs:{target:"_blank",href:n.url}},n.name)}return"服务条款:"===t.row.k1?e("a",{attrs:{target:"_blank",href:t.row.k2}},t.row.k2):"开发人员:"===t.row.k1?e("a",{attrs:{target:"_blank",href:"mailto:"+t.row.k2}},t.row.k2):e("span",{},t.row.k2)}var $e=Se,xe=Object(w["a"])($e,we,be,!1,null,"48d57106",null),_e=xe.exports;r["a"].use(ye["a"]);var Oe=new ye["a"]({base:"",routes:[{path:"/",name:"Home",component:_e},{path:"/entity/:id",name:"EntityView",component:function(){return n.e("entity-view").then(n.bind(null,"6ec6"))}}]}),Pe=(n("dcad"),n("a8ee")),Me=n("117e"),Ce=n("a49b"),Ee=n("10aa"),Ie=n("01f8"),je=n("2d66"),Te=n("f2d8"),Ae=n("d842"),Je=n("107e"),De=n("ba47"),Re=n("6be2"),Le=n("6bf4"),Be=n("9968"),qe=n("097a"),Ne=n("cf8e"),Fe=n("f69c"),He=n("093f"),Ke=n("9897"),Ue=n("7d1f"),We=n("cfa5"),Ge=n("d3b2"),ze=n("70ae"),Ve=n("71a9"),Qe=n("bf7a"),Ye=n("9e6d"),Xe=n("d914"),Ze=n("ac2e"),et=n("1960");r["a"].prototype.$IVIEW={modal:{maskClosable:""},menu:{customArrow:""}},r["a"].component("Layout",et["a"]),r["a"].component("Header",Ze["a"]),r["a"].component("Content",Xe["a"]),r["a"].component("Menu",Ye["a"]),r["a"].component("MenuItem",Qe["a"]),r["a"].component("Submenu",Ve["a"]),r["a"].component("Sider",ze["a"]),r["a"].component("Icon",Ge["a"]),r["a"].component("Affix",We["a"]),r["a"].component("Tooltip",Ue["a"]),r["a"].component("AutoComplete",Ke["a"]),r["a"].component("Option",He["a"]),r["a"].component("Divider",Fe["a"]),r["a"].component("Table",Ne["a"]),r["a"].component("Anchor",qe["a"]),r["a"].component("AnchorLink",Be["a"]),r["a"].component("Tag",Le["a"]),r["a"].component("Modal",Re["a"]),r["a"].component("CellGroup",De["a"]),r["a"].component("Cell",Je["a"]),r["a"].component("Form",Ae["a"]),r["a"].component("FormItem",Te["a"]),r["a"].component("Input",je["a"]),r["a"].component("Button",Ie["a"]),r["a"].component("Radio",Ee["a"]),r["a"].component("RadioGroup",Ce["a"]),r["a"].prototype.$Message=Me["a"],r["a"].prototype.$Notice=Pe["a"],r["a"].config.productionTip=!1,new r["a"]({router:Oe,data:function(){return{isCollapsed:!1,activeMenu:{submenu:[],menuItem:""},swaggerResources:[],currentSwaggerJson:{}}},beforeCreate:function(){L.initApi(["/swagger-resources","/swagger-resources.json"],this)},render:function(e){return e(ve)}}).$mount("#app")},"5c48":function(e,t,n){},"7c55":function(e,t,n){"use strict";var r=n("5c48"),a=n.n(r);a.a},"805c":function(e,t,n){"use strict";var r=n("d874"),a=n.n(r);a.a},"97a0":function(e,t,n){"use strict";var r=n("e9a8"),a=n.n(r),o=n("dd61"),i=n.n(o),s=n("6edf"),c=n.n(s),u=n("ded5"),l=n.n(u),p=n("020f"),f=n.n(p),m=n("e2a0"),d=n.n(m),h=n("9b02"),g=n.n(h),v=n("81be"),y=n.n(v),w=n("6747"),b=n.n(w),S=n("0f40"),k=n.n(S),$=n("2acb"),x=n.n($),_=n("c707"),O=n.n(_),P=n("6625"),M=n.n(P),C=n("c04c"),E=n.n(C);t["a"]={flatMap:a.a,map:i.a,groupBy:c.a,forOwn:f.a,join:l.a,get:g.a,isString:d.a,endsWith:y.a,isArray:b.a,random:k.a,slice:x.a,sortBy:O.a,split:M.a,remove:E.a}},a9a7:function(e,t,n){},b51a:function(e,t,n){"use strict";n("aef6"),n("f559"),n("7514"),n("ac4d"),n("8a81"),n("ac6a"),n("7f7f");var r=n("97a0"),a=n("d958"),o=n.n(a);function i(e){var t={license:{}};Object.assign(t,e.info);var n={info:t,beanMap:u(e.definitions),definitions:e.definitions};n.info.host=e.host,n.info.basePath=e.basePath,n.info.schemes=e.schemes;var a=0,o=r["a"].flatMap(e.paths,function(t,o){return r["a"].flatMap(t,function(t,i){return r["a"].map(t.tags,function(r){return c({id:a++,tag:r,name:t.summary,path:o,method:i.toUpperCase(),deprecated:t.deprecated,produces:t.produces,consumes:t.consumes,description:t.description,paramBean:f(t.parameters,e.definitions),responseBean:m(t.responses,e.definitions,n)},n.beanMap)})})});return n.collection=r["a"].groupBy(r["a"].sortBy(o,"tag"),"tag"),n}function s(e){var t=o()(e,{style:o.a.STYLE_NORMAL});return r["a"].join(r["a"].flatMap(t)," ")}function c(e,t){return e.tagPinyin=s(e.tag),e.namePinyin=s(e.name),e.paramSubBeans=l(e.paramBean,t),e.responseSubBeans=l(e.responseBean,t),e}function u(e){var t={};return r["a"].forOwn(e,function(n,a){var o=O();o.title=n.title||a,o.type=n.type,o.props=r["a"].map(n.properties,function(t,n){return h({name:n,description:t.description},t,e)}),o.schemaKey=a,t[a]=o}),t}function l(e,t){var n=[];return p(e,t,n),n}function p(e,t,n){if(!e||!t||!e.props)return O();var r=!0,a=!1,o=void 0;try{for(var i,s=function(){var e=i.value;if(e.hasRef&&t.hasOwnProperty(e.schemaKey)){var r=t[e.schemaKey];r&&0===n.filter(function(t){return t.schemaKey===e.schemaKey}).length&&(n.push(r),p(r,t,n))}},c=e.props[Symbol.iterator]();!(r=(i=c.next()).done);r=!0)s()}catch(u){a=!0,o=u}finally{try{r||null==c.return||c.return()}finally{if(a)throw o}}}function f(e,t){if(!e)return O();var n=O();return n.props=r["a"].sortBy(e,"in").map(function(e){var n={};return n.name=e.name,n.description=e.description,n.in=e.in,n.required=e.required,h(n,e,t)}),n}function m(e,t,n){var a=O();return a.props=r["a"].map(e,function(e,r){if($(e)){var a=_(e,t);n.beanMap=u(t),e=a}return h({status:r,description:e.description},e,t)}),a}function d(e,t){return r["a"].flatMap(e).find(function(e){return e.id+""===t})}function h(e,t,n){e.type=g(t,n),e.format=v(t,n);var a=w(t);return e.hasRef=r["a"].isString(a),e.schemaKey=b(a),e.constraint="",t.enum&&(e.constraint+=" enum: "+r["a"].join(t.enum,", ")),t.minLength&&(e.constraint+=" minLength: "+t.minLength),t.maxLength&&(e.constraint+=" minLength: "+t.maxLength),t.pattern&&(e.constraint+=" pattern: "+t.pattern),e}function g(e,t){if("array"===e.type&&e.items&&e.items.type)return"["+e.items.type+"]";if("array"===r["a"].get(e,"schema.type")&&r["a"].get(e,"schema.items.type"))return"["+e.schema.items.type+"]";var n=b(w(e));return"array"===e.type&&n?"["+S(n,t)+"]":"array"===r["a"].get(e,"schema.type")&&n?"["+S(n,t)+"]":n?S(n,t):r["a"].get(e,"schema.type")?e.schema.type:e.type}function v(e,t){var n=r["a"].get(e,"schema.items.format");if(n)return n;var a=w(e);if(a){var o=b(a),i=k(o,t);return i||o}return e.format}function y(e,t){var n=b(e);if(t.hasOwnProperty(n))return t[n]}function w(e){return r["a"].get(e,"$ref")||r["a"].get(e,"schema.$ref")||r["a"].get(e,"items.$ref")||r["a"].get(e,"schema.items.$ref")}function b(e){var t="#/definitions/";if(e&&e.startsWith(t))return e.substring(t.length)}function S(e,t){if(t.hasOwnProperty(e))return t[e].type;if(r["a"].endsWith(e,"«object»")){var n=e.substring(0,e.length-"«object»".length);return r["a"].get(t,[n,"type"])}}function k(e,t){if(t.hasOwnProperty(e))return t[e].title}function $(e){return!!r["a"].get(e,"schema.properties")||!!r["a"].get(e,"schema.allOf")}var x=0;function _(e,t){var n="_MergeSchema"+x++,a={type:"object",title:n,properties:{}};if(r["a"].isArray(r["a"].get(e,"schema.allOf"))){var o=!0,i=!1,s=void 0;try{for(var c,u=e.schema.allOf[Symbol.iterator]();!(o=(c=u.next()).done);o=!0){var l=c.value;if(l.hasOwnProperty("$ref")){var p=y(l["$ref"],t);p.properties&&Object.assign(a.properties,p.properties)}}}catch(m){i=!0,s=m}finally{try{o||null==u.return||u.return()}finally{if(i)throw s}}}var f=r["a"].get(e,"schema.properties");return f&&r["a"].forOwn(f,function(n,o){if(r["a"].isArray(n.allOf)){var i="_MergeSchema"+x++,s={type:"object",title:i,properties:{}},c=!0,u=!1,l=void 0;try{for(var p,f=n.allOf[Symbol.iterator]();!(c=(p=f.next()).done);c=!0){var d=p.value;if(d.hasOwnProperty("$ref")){var h=y(d["$ref"],t);h.properties&&Object.assign(s.properties,h.properties)}}}catch(m){u=!0,l=m}finally{try{c||null==f.return||f.return()}finally{if(u)throw l}}t[i]=s;var g={};g[o]={description:e.description,schema:{$ref:"#/definitions/"+i}},Object.assign(a.properties,g)}}),t[n]=a,{description:e.description,schema:{$ref:"#/definitions/"+n}}}function O(){return{title:"",type:"",props:[]}}t["a"]={fixSwaggerJson:i,findHttpEntity:d}},d7f5:function(e,t,n){},d874:function(e,t,n){}}); -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/js/app.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/js/app.js.gz -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/js/chunk-vendors.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/js/chunk-vendors.js.gz -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/js/entity-view.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["entity-view"],{"491b":function(t,e,n){},"6ec6":function(t,e,n){"use strict";n.r(e);var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticStyle:{padding:"24px 0 0 24px"}},[n("div",{staticClass:"divider-auto"},[n("Divider",[n("h2",[t._v(t._s(t.httpEntity.name))])])],1),n("div",{attrs:{id:"doc-content"}},[n("ul",[t._m(0),n("li",{staticClass:"no-border"},[n("EntityViewApiInfo",{attrs:{httpEntity:t.httpEntity}})],1),t._m(1),n("li",[n("EntityViewParam",{attrs:{httpEntity:t.httpEntity}})],1),t._l(t.httpEntity.paramSubBeans,function(e,r){return[n("li",{key:"h3_param_"+e.schemaKey},[n("h3",{attrs:{id:"h3_param_"+r}},[n("Icon",{attrs:{type:"md-arrow-dropright",size:"20"}}),t._v(t._s(e.title))],1)]),n("li",{key:"param_"+e.schemaKey},[n("EntityViewBean",{attrs:{props:e.props}})],1)]}),t._m(2),n("li",[n("EntityViewResponse",{attrs:{httpEntity:t.httpEntity}})],1),t._l(t.httpEntity.responseSubBeans,function(e,r){return[n("li",{key:"h3_response_"+e.schemaKey},[n("h3",{attrs:{id:"h3_response_"+r}},[n("Icon",{attrs:{type:"md-arrow-dropright",size:"20"}}),t._v(t._s(e.title))],1)]),n("li",{key:"response_"+e.schemaKey},[n("EntityViewBean",{attrs:{props:e.props}})],1)]})],2)]),n("div",{staticClass:"anchor-auto"},[n("Anchor",{attrs:{"show-ink":"",container:"#doc-content"}},[n("AnchorLink",{attrs:{href:"#h2_1",title:"# 接口说明"}}),n("AnchorLink",{attrs:{href:"#h2_2",title:"# 请求参数"}}),t._l(t.httpEntity.paramSubBeans,function(t,e){return n("AnchorLink",{key:"h3_param_"+t.schemaKey,attrs:{href:"#h3_param_"+e,title:t.title}})}),n("AnchorLink",{attrs:{href:"#h2_3",title:"# 响应信息"}}),t._l(t.httpEntity.responseSubBeans,function(t,e){return n("AnchorLink",{key:"h3_response_"+t.schemaKey,attrs:{href:"#h3_response_"+e,title:t.title}})})],2)],1)])},i=[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("li",[n("h2",{attrs:{id:"h2_1"}},[t._v("接口说明")])])},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("li",[n("h2",{attrs:{id:"h2_2"}},[t._v("请求参数")])])},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("li",[n("h2",{attrs:{id:"h2_3"}},[t._v("响应信息")])])}],a=n("b51a"),s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("Table",{attrs:{columns:t.apiInfoColumns,data:t.apiInfo,"show-header":!1,size:"small"}})},o=[],p=(n("7f7f"),function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("Tooltip",{attrs:{content:"点击复制",placement:"right-start"}},[n("span",{staticClass:"copied-tag",on:{click:t.copyToClipboard}},[t._t("default")],2)])}),l=[],c=n("b311"),u=n.n(c),h={name:"CopiedTag",methods:{copyToClipboard:function(){new u.a(".copied-tag",{text:function(t){return t.innerHTML}}),this.$Message.success("复制成功")}}},m=h,y=n("2877"),d=Object(y["a"])(m,p,l,!1,null,null,null),f=d.exports,_=n("97a0");function E(t,e){var n=e.row.name||e.row.k2;return _["a"].isArray(n)?(n=n.map(function(e){return t(f,{style:"margin-right:10px"},e)}),t("span",{},n)):t(f,{},n)}var k={name:"EntityViewApiInfo",data:function(){return{apiInfoColumns:[{title:"",key:"k1",width:110,align:"right",render:v},{title:"",key:"k2",render:E}]}},computed:{apiInfo:function(){var t=[{k1:this.httpEntity.method,k2:this.httpEntity.path},{k1:"请求体类型",k2:this.httpEntity.consumes},{k1:"响应体类型",k2:this.httpEntity.produces},{k1:"描述",k2:this.httpEntity.description}];return"GET"===this.httpEntity.method&&t.splice(1,1),t}},props:{httpEntity:{type:Object,required:!0}}},w={GET:"success",POST:"warning",PUT:"primary",DELETE:"error"};function v(t,e){if(0===e.index){var n=w[e.row.k1]||"default";return t("Tag",{props:{color:n}},e.row.k1)}return t("span",e.row.k1)}var b=k,x=Object(y["a"])(b,s,o,!1,null,null,null),g=x.exports,C=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("Table",{attrs:{columns:t.paramBeanColumns,data:t.httpEntity.paramBean.props,border:"",size:"small"},scopedSlots:t._u([{key:"name",fn:function(e){var r=e.row;e.index;return[!0===r.required?n("span",{staticStyle:{color:"red"}},[n("CopiedTag",[t._v(t._s(r.name))]),t._v(" *")],1):n("CopiedTag",[t._v(t._s(r.name))])]}}])})},B=[],T={name:"EntityViewParam",components:{CopiedTag:f},data:function(){return{paramBeanColumns:[{title:"名称",key:"name",maxWidth:150,slot:"name"},{title:"描述",key:"description"},{title:"位置",key:"in",maxWidth:100,render:W},{title:"类型",key:"type",maxWidth:100},{title:"格式",key:"format",maxWidth:150},{title:"约束",key:"constraint",maxWidth:250}]}},props:{httpEntity:{type:Object,required:!0}}},V={header:"#ED4015",path:"#2D8CF0",query:"#18BE6B",body:"#FF9901"};function W(t,e){var n=V[e.row.in]||"#7a7a7a";return t("span",{style:"color:".concat(n,";font-weight:bold;")},e.row.in)}var $=T,A=Object(y["a"])($,C,B,!1,null,null,null),O=A.exports,S=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("Table",{attrs:{columns:t.responseBeanColumns,data:t.httpEntity.responseBean.props,border:"",size:"small"}})},j=[],I={name:"EntityViewResponse",data:function(){return{responseBeanColumns:[{title:"状态",key:"status",maxWidth:62},{title:"描述",key:"description"},{title:"类型",key:"type",maxWidth:100},{title:"格式",key:"format",maxWidth:150},{title:"约束",key:"constraint",maxWidth:250}]}},props:{httpEntity:{type:Object,required:!0}}},L=I,q=Object(y["a"])(L,S,j,!1,null,"6a916fce",null),z=q.exports,K=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("Table",{attrs:{columns:t.beanColumns,data:t.props,border:"",size:"small"}})},P=[],D={name:"EntityViewBean",data:function(){return{beanColumns:[{title:"名称",key:"name",maxWidth:150,render:J},{title:"描述",key:"description"},{title:"类型",key:"type",maxWidth:100},{title:"格式",key:"format",maxWidth:150},{title:"约束",key:"constraint",maxWidth:250}]}},props:{props:{type:Array,required:!0}}};function J(t,e){var n=e.row.name||e.row.k2;return _["a"].isArray(n)?(n=n.map(function(e){return t(f,{style:"margin-right:10px"},e)}),t("span",{},n)):t(f,{},n)}var F=D,R=Object(y["a"])(F,K,P,!1,null,null,null),G=R.exports,H={name:"EntityView",components:{EntityViewApiInfo:g,EntityViewParam:O,EntityViewResponse:z,EntityViewBean:G},computed:{httpEntity:function(){return this.$root.currentSwaggerJson.collection?a["a"].findHttpEntity(this.$root.currentSwaggerJson.collection,this.$route.params.id):{paramBean:{props:[]},responseBean:{props:[]}}}}},M=H,U=(n("d2e6"),Object(y["a"])(M,r,i,!1,null,null,null)),N=U.exports;e["default"]=N},d2e6:function(t,e,n){"use strict";var r=n("491b"),i=n.n(r);i.a}}]); -------------------------------------------------------------------------------- /dist/webjars/swagger-document-ui/js/entity-view.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/dist/webjars/swagger-document-ui/js/entity-view.js.gz -------------------------------------------------------------------------------- /docs/demo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/docs/demo1.png -------------------------------------------------------------------------------- /docs/demo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/docs/demo2.png -------------------------------------------------------------------------------- /docs/demo3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/docs/demo3.png -------------------------------------------------------------------------------- /docs/demo4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/docs/demo4.png -------------------------------------------------------------------------------- /docs/postman1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/docs/postman1.png -------------------------------------------------------------------------------- /docs/postman2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/docs/postman2.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-document-ui", 3 | "version": "1.0.2", 4 | "license": "Apache-2.0", 5 | "repository": "https://github.com/cn-src/swagger-document-ui.git", 6 | "contributors": [ 7 | "cn-src " 8 | ], 9 | "scripts": { 10 | "serve": "vue-cli-service serve", 11 | "build": "vue-cli-service build", 12 | "lint": "vue-cli-service lint", 13 | "test:unit": "vue-cli-service test:unit" 14 | }, 15 | "dependencies": { 16 | "axios": "^0.19.0", 17 | "clipboard": "^2.0.4", 18 | "file-saver": "^2.0.2", 19 | "fuse.js": "^3.4.5", 20 | "iview": "^3.4.2", 21 | "lodash": "^4.17.11", 22 | "pinyin": "^2.9.0", 23 | "vue": "^2.6.10", 24 | "vue-router": "^3.0.7" 25 | }, 26 | "devDependencies": { 27 | "@babel/core": "^7.5.0", 28 | "@babel/preset-env": "^7.5.0", 29 | "@vue/cli-plugin-babel": "^3.9.0", 30 | "@vue/cli-plugin-eslint": "^3.9.1", 31 | "@vue/cli-plugin-unit-jest": "^3.9.0", 32 | "@vue/cli-service": "^3.9.0", 33 | "@vue/test-utils": "^1.0.0-beta.29", 34 | "babel-core": "7.0.0-bridge.0", 35 | "babel-jest": "^24.8.0", 36 | "babel-plugin-import": "^1.12.0", 37 | "compression-webpack-plugin": "^3.0.0", 38 | "font-spider": "^1.3.4", 39 | "jest": "^24.8.0", 40 | "less": "^3.9.0", 41 | "less-loader": "^5.0.0", 42 | "prettier": "1.18.2", 43 | "vue-cli-plugin-pug": "^1.0.7", 44 | "vue-template-compiler": "^2.6.10" 45 | }, 46 | "babel": { 47 | "presets": [ 48 | "@babel/preset-env", 49 | "@vue/app" 50 | ], 51 | "plugins": [ 52 | [ 53 | "import", 54 | { 55 | "libraryName": "iview", 56 | "libraryDirectory": "src/components" 57 | } 58 | ] 59 | ] 60 | }, 61 | "eslintConfig": { 62 | "root": true, 63 | "env": { 64 | "node": true 65 | }, 66 | "extends": [ 67 | "plugin:vue/essential", 68 | "eslint:recommended" 69 | ], 70 | "rules": { 71 | "no-console": "off" 72 | }, 73 | "parserOptions": { 74 | "parser": "babel-eslint" 75 | } 76 | }, 77 | "postcss": { 78 | "plugins": { 79 | "autoprefixer": {} 80 | } 81 | }, 82 | "browserslist": [ 83 | "> 1%", 84 | "last 2 versions", 85 | "not ie <= 8" 86 | ], 87 | "jest": { 88 | "moduleFileExtensions": [ 89 | "js", 90 | "jsx", 91 | "json", 92 | "vue" 93 | ], 94 | "transform": { 95 | "^.+\\.vue$": "vue-jest", 96 | ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub", 97 | "^.+\\.jsx?$": "babel-jest" 98 | }, 99 | "moduleNameMapper": { 100 | "^@/(.*)$": "/src/$1" 101 | }, 102 | "snapshotSerializers": [ 103 | "jest-serializer-vue" 104 | ], 105 | "testMatch": [ 106 | "**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)" 107 | ], 108 | "testURL": "http://localhost/" 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | API 文档 9 | 10 | 11 | 17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /public/webjars/swagger-document-ui/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cn-src/swagger-document-ui/2457feb75b67e1c6ea62a69c9abd951df02bc86c/public/webjars/swagger-document-ui/favicon.ico -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 19 | 38 | 52 | -------------------------------------------------------------------------------- /src/components/CopiedTag.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 23 | -------------------------------------------------------------------------------- /src/components/ExportPostman.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 62 | 68 | -------------------------------------------------------------------------------- /src/components/MethodTag.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 37 | 38 | 48 | -------------------------------------------------------------------------------- /src/components/SearchInput.vue: -------------------------------------------------------------------------------- 1 | 13 | 58 | -------------------------------------------------------------------------------- /src/components/SwaggerResources.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 35 | 41 | -------------------------------------------------------------------------------- /src/iview-clip.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 精简 iview 。 3 | */ 4 | import Vue from 'vue'; 5 | import { 6 | Layout, 7 | Header, 8 | Content, 9 | Menu, 10 | MenuItem, 11 | Submenu, 12 | Sider, 13 | Icon, 14 | Affix, 15 | Tooltip, 16 | AutoComplete, 17 | Option, 18 | Divider, 19 | Table, 20 | Anchor, 21 | AnchorLink, 22 | Tag, 23 | Modal, 24 | CellGroup, 25 | Cell, 26 | Message, 27 | Notice, 28 | Form, 29 | FormItem, 30 | Input, 31 | Button, 32 | Radio, 33 | RadioGroup 34 | } from 'iview'; 35 | 36 | Vue.prototype.$IVIEW = { modal: { maskClosable: '' }, menu: { customArrow: '' } }; 37 | Vue.component('Layout', Layout); 38 | Vue.component('Header', Header); 39 | Vue.component('Content', Content); 40 | Vue.component('Menu', Menu); 41 | Vue.component('MenuItem', MenuItem); 42 | Vue.component('Submenu', Submenu); 43 | Vue.component('Sider', Sider); 44 | Vue.component('Icon', Icon); 45 | Vue.component('Affix', Affix); 46 | Vue.component('Tooltip', Tooltip); 47 | Vue.component('AutoComplete', AutoComplete); 48 | Vue.component('Option', Option); 49 | Vue.component('Divider', Divider); 50 | Vue.component('Table', Table); 51 | Vue.component('Anchor', Anchor); 52 | Vue.component('AnchorLink', AnchorLink); 53 | Vue.component('Tag', Tag); 54 | Vue.component('Modal', Modal); 55 | Vue.component('CellGroup', CellGroup); 56 | Vue.component('Cell', Cell); 57 | Vue.component('Form', Form); 58 | Vue.component('FormItem', FormItem); 59 | Vue.component('Input', Input); 60 | Vue.component('Button', Button); 61 | Vue.component('Radio', Radio); 62 | Vue.component('RadioGroup', RadioGroup); 63 | 64 | Vue.prototype.$Message = Message; 65 | Vue.prototype.$Notice = Notice; 66 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import 'iview/dist/styles/iview.css'; 5 | import api from '@/utils/api' 6 | import './iview-clip' 7 | 8 | Vue.config.productionTip = false; 9 | 10 | new Vue({ 11 | router, 12 | // 项目小,使用 $root 做全局状态管理 13 | data() { 14 | return { 15 | isCollapsed: false, 16 | activeMenu: {submenu: [], menuItem: ''}, 17 | swaggerResources: [], 18 | currentSwaggerJson: {} 19 | } 20 | }, 21 | beforeCreate() { 22 | api.initApi(['/swagger-resources', '/swagger-resources.json'], this); 23 | }, 24 | render: h => h(App) 25 | }).$mount('#app'); 26 | -------------------------------------------------------------------------------- /src/router.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Home from '@/views/Home' 4 | 5 | Vue.use(Router); 6 | 7 | export default new Router({ 8 | // mode: 'history', 9 | base: process.env.BASE_URL, 10 | routes: [ 11 | { 12 | path: '/', 13 | name: 'Home', 14 | component: Home 15 | }, 16 | { 17 | path: '/entity/:id', 18 | name: 'EntityView', 19 | // route level code-splitting 20 | // this generates a separate chunk (about.[hash].js) for this route 21 | // which is lazy-loaded when the route is visited. 22 | component: () => import(/* webpackChunkName: "entity-view" */ './views/entity-view') 23 | } 24 | ] 25 | }) 26 | -------------------------------------------------------------------------------- /src/utils/$.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 精简 lodash,以及自定义工具方法。 3 | */ 4 | 5 | import flatMap from 'lodash/flatMap'; 6 | import map from 'lodash/map'; 7 | import groupBy from 'lodash/groupBy'; 8 | import join from 'lodash/join'; 9 | import forOwn from 'lodash/forOwn'; 10 | import isString from 'lodash/isString'; 11 | import get from 'lodash/get'; 12 | import endsWith from 'lodash/endsWith'; 13 | import isArray from 'lodash/isArray'; 14 | import random from 'lodash/random'; 15 | import slice from 'lodash/slice'; 16 | import sortBy from 'lodash/sortBy'; 17 | import split from 'lodash/split'; 18 | import remove from 'lodash/remove'; 19 | 20 | export default { 21 | flatMap, 22 | map, 23 | groupBy, 24 | forOwn, 25 | join, 26 | get, 27 | isString, 28 | endsWith, 29 | isArray, 30 | random, 31 | slice, 32 | sortBy, 33 | split, 34 | remove 35 | }; 36 | -------------------------------------------------------------------------------- /src/utils/api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * http 接口初始化以及调用。 3 | */ 4 | import axios from 'axios'; 5 | import swagger from '@/utils/swagger'; 6 | import $ from '@/utils/$'; 7 | 8 | function initApi(paths, $root) { 9 | configAxios($root); 10 | if (!$.isArray(paths)) { 11 | paths = [paths]; 12 | } 13 | const swaggerResources = []; 14 | axios 15 | .all( 16 | paths.map(url => 17 | axios.get(url).catch(res => { 18 | console.info(`[swagger-document-ui]: Can not get url '${url}', res: ` + res); 19 | }) 20 | ) 21 | ) 22 | .then(function(results) { 23 | $.flatMap(results, function(it) { 24 | return it ? it.data : []; 25 | }).forEach(function(data) { 26 | swaggerResources.push(data); 27 | }); 28 | 29 | $root.swaggerResources = swaggerResources; 30 | if (swaggerResources[0]) { 31 | const url = swaggerResources[0].url || swaggerResources[0].location; 32 | setCurrentSwaggerJson(url, $root); 33 | } else { 34 | console.warn('[swagger-document-ui]: Can not find url, swaggerResources: ' + swaggerResources); 35 | $root.$Notice.warning({ 36 | title: 'API 初始化错误', 37 | desc: '未找到 API 地址', 38 | duration: 10 39 | }); 40 | } 41 | }); 42 | } 43 | 44 | function setCurrentSwaggerJson(path, vue, onSuccess) { 45 | axios.get(path).then(function(swaggerResponse) { 46 | const data = swaggerResponse.data; 47 | let swaggerJson; 48 | if (typeof data === 'string') { 49 | try { 50 | swaggerJson = JSON.parse(data); 51 | } catch (e) { 52 | console.warn('[swagger-document-ui]: Parse swagger json error: ' + e); 53 | vue.$root.$Notice.error({ 54 | title: 'API 初始化错误', 55 | desc: `path: ${path}\n${e.toLocaleString()}`, 56 | duration: 10 57 | }); 58 | } 59 | } else { 60 | swaggerJson = data; 61 | } 62 | onSuccess && onSuccess(); 63 | vue.$root.currentSwaggerJson = swagger.fixSwaggerJson(swaggerJson); 64 | }); 65 | } 66 | 67 | function configAxios($root) { 68 | const baseURL = getBaseURL(); 69 | $root.baseURL = baseURL; 70 | axios.defaults.baseURL = baseURL; 71 | axios.defaults.timeout = 10000; 72 | axios.interceptors.response.use( 73 | response => { 74 | return response; 75 | }, 76 | error => { 77 | const url = $.get(error, 'request.responseURL'); 78 | if ( 79 | url && 80 | $.get(error, 'response.status') === 404 && 81 | ($.endsWith(url, '/swagger-resources.json') || $.endsWith(url, '/swagger-resources')) 82 | ) { 83 | console.info(`[swagger-document-ui]: '${url}' 404`); 84 | } else { 85 | console.warn('[swagger-document-ui]: Ajax error: ' + error); 86 | $root.$Notice.error({ 87 | title: 'Error', 88 | desc: error, 89 | duration: 10 90 | }); 91 | } 92 | 93 | return Promise.reject($.get(error, 'response.data')); 94 | } 95 | ); 96 | } 97 | 98 | const getBaseURL = () => { 99 | const urlMatches = /(.*)\/swagger-ui.html.*/.exec(window.location.href); 100 | return urlMatches !== null ? urlMatches[1] : '/'; 101 | }; 102 | export default { initApi, setCurrentSwaggerJson }; 103 | -------------------------------------------------------------------------------- /src/utils/postman.js: -------------------------------------------------------------------------------- 1 | import $ from './$'; 2 | 3 | function parseUrl(url, basePath) { 4 | const a = document.createElement('a'); 5 | a.href = basePath; 6 | url.protocol = a.protocol.substring(0, a.protocol.length - 1); 7 | url.host = a.hostname.split('.'); 8 | url.port = a.port; 9 | url.path = $.remove([...$.split(a.pathname, '/'), ...url.path], it => it !== '').map(it => { 10 | if (it.match(/{.+}/)) { 11 | let pathVar = it.substring(1, it.length - 1); 12 | if (!url.variable) { 13 | url.variable = []; 14 | } 15 | url.variable.push({ key: pathVar }); 16 | return ':' + pathVar; 17 | } else { 18 | return it; 19 | } 20 | }); 21 | } 22 | 23 | function parseParam(url, paramBean) { 24 | paramBean.props.forEach(prop => { 25 | if (prop.in === 'query') { 26 | if (!url.query) { 27 | url.query = []; 28 | } 29 | url.query.push({ key: prop.name, disabled: !prop.required }); 30 | } 31 | }); 32 | } 33 | 34 | function exportJson(fixedSwaggerJson, config) { 35 | const postman = { 36 | info: { schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json' }, 37 | item: [] 38 | }; 39 | postman.info.name = fixedSwaggerJson.info.title; 40 | 41 | $.forOwn(fixedSwaggerJson.collection, (httpEntities, tag) => { 42 | const tagItem = { 43 | name: tag, 44 | item: [] 45 | }; 46 | postman.item.push(tagItem); 47 | httpEntities.forEach(httpEntity => { 48 | const item = { 49 | name: httpEntity.name, 50 | request: { 51 | method: httpEntity.method, 52 | header: [], 53 | url: { path: $.split(httpEntity.path, '/') } 54 | } 55 | }; 56 | parseUrl(item.request.url, config.basePath); 57 | parseParam(item.request.url, httpEntity.paramBean); 58 | if (httpEntity.consumes && httpEntity.consumes.length > 0) { 59 | item.request.header.push({ key: 'Content-Type', value: httpEntity.consumes[0] }); 60 | } 61 | tagItem.item.push(item); 62 | }); 63 | }); 64 | return JSON.stringify(postman); 65 | } 66 | 67 | export default { exportJson }; 68 | -------------------------------------------------------------------------------- /src/utils/swagger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 将 swagger json 转成渲染所需的结构,并添加部分字段的拼音。 3 | */ 4 | import $ from '@/utils/$'; 5 | import pinyin from 'pinyin'; 6 | 7 | function fixSwaggerJson(swaggerJson) { 8 | const info = { license: {} }; 9 | Object.assign(info, swaggerJson.info); 10 | let data = { 11 | info: info, 12 | beanMap: fixBeanMap(swaggerJson.definitions), 13 | definitions: swaggerJson.definitions 14 | }; 15 | data.info.host = swaggerJson.host; 16 | data.info.basePath = swaggerJson.basePath; 17 | data.info.schemes = swaggerJson.schemes; 18 | 19 | let index = 0; 20 | const httpEntities = $.flatMap(swaggerJson.paths, (pathInfo, path) => { 21 | return $.flatMap(pathInfo, (methodInfo, methodType) => { 22 | return $.map(methodInfo.tags, tag => { 23 | return fixHttpEntity( 24 | { 25 | id: index++, 26 | tag: tag, 27 | name: methodInfo.summary, 28 | path: path, 29 | method: methodType.toUpperCase(), 30 | deprecated: methodInfo.deprecated, 31 | produces: methodInfo.produces, 32 | consumes: methodInfo.consumes, 33 | description: methodInfo.description, 34 | paramBean: fixParamsToBean(methodInfo.parameters, swaggerJson.definitions), 35 | responseBean: fixResponsesToBean(methodInfo.responses, swaggerJson.definitions, data) 36 | }, 37 | data.beanMap 38 | ); 39 | }); 40 | }); 41 | }); 42 | 43 | data.collection = $.groupBy($.sortBy(httpEntities, 'tag'), 'tag'); 44 | return data; 45 | } 46 | 47 | function toPinyin(text) { 48 | const pyArray = pinyin(text, { style: pinyin.STYLE_NORMAL }); 49 | return $.join($.flatMap(pyArray), ' '); 50 | } 51 | 52 | function fixHttpEntity(httpEntity, beanMap) { 53 | httpEntity.tagPinyin = toPinyin(httpEntity.tag); 54 | httpEntity.namePinyin = toPinyin(httpEntity.name); 55 | httpEntity.paramSubBeans = findAllBean(httpEntity.paramBean, beanMap); 56 | httpEntity.responseSubBeans = findAllBean(httpEntity.responseBean, beanMap); 57 | return httpEntity; 58 | } 59 | 60 | function fixBeanMap(definitions) { 61 | const beanMap = {}; 62 | $.forOwn(definitions, (schema, schemaKey) => { 63 | let bean = emptyBean(); 64 | bean.title = schema.title || schemaKey; 65 | bean.type = schema.type; 66 | bean.props = $.map(schema.properties, (prop, propName) => { 67 | return fixBean( 68 | { 69 | name: propName, 70 | description: prop.description 71 | }, 72 | prop, 73 | definitions 74 | ); 75 | }); 76 | bean.schemaKey = schemaKey; 77 | beanMap[schemaKey] = bean; 78 | }); 79 | return beanMap; 80 | } 81 | 82 | function findAllBean(bean, beanMap) { 83 | const childBean = []; 84 | recursiveAllBean(bean, beanMap, childBean); 85 | return childBean; 86 | } 87 | 88 | /** 89 | * 根据参数,尾递归找到所有的Schema信息. 90 | */ 91 | function recursiveAllBean(bean, beanMap, childBean) { 92 | if (!bean || !beanMap || !bean.props) { 93 | return emptyBean(); 94 | } 95 | for (let prop of bean.props) { 96 | if (prop.hasRef && beanMap.hasOwnProperty(prop.schemaKey)) { 97 | const child = beanMap[prop.schemaKey]; 98 | if ( 99 | child && 100 | childBean.filter(fb => { 101 | return fb.schemaKey === prop.schemaKey; 102 | }).length === 0 103 | ) { 104 | childBean.push(child); 105 | recursiveAllBean(child, beanMap, childBean); 106 | } 107 | } 108 | } 109 | } 110 | 111 | /** 112 | * 标准化请求参数,便于渲染. 113 | */ 114 | function fixParamsToBean(parameters, definitions) { 115 | if (!parameters) { 116 | return emptyBean(); 117 | } 118 | let bean = emptyBean(); 119 | 120 | bean.props = $.sortBy(parameters, 'in').map(schema => { 121 | const propBean = {}; 122 | propBean.name = schema.name; 123 | propBean.description = schema.description; 124 | propBean.in = schema.in; 125 | propBean.required = schema.required; 126 | return fixBean(propBean, schema, definitions); 127 | }); 128 | 129 | return bean; 130 | } 131 | 132 | function fixResponsesToBean(responses, definitions, data) { 133 | let bean = emptyBean(); 134 | bean.props = $.map(responses, (schema, status) => { 135 | if (isMergeSchema(schema)) { 136 | const mergeSchema = createMergeSchema(schema, definitions); 137 | data.beanMap = fixBeanMap(definitions); 138 | schema = mergeSchema; 139 | } 140 | return fixBean( 141 | { 142 | status: status, 143 | description: schema.description 144 | }, 145 | schema, 146 | definitions 147 | ); 148 | }); 149 | return bean; 150 | } 151 | 152 | function findHttpEntity(collection, id) { 153 | return $.flatMap(collection).find(v => { 154 | // 菜单传过来的 id 是 string 类型 155 | return v.id + '' === id; 156 | }); 157 | } 158 | 159 | function fixBean(bean, schema, definitions) { 160 | bean.type = fixType(schema, definitions); 161 | bean.format = fixFormat(schema, definitions); 162 | const schemaRef = getSchemaRef(schema); 163 | bean.hasRef = $.isString(schemaRef); 164 | bean.schemaKey = getSchemaKey(schemaRef); 165 | bean.constraint = ''; 166 | if (schema.enum) { 167 | bean.constraint += ' enum: ' + $.join(schema.enum, ', '); 168 | } 169 | if (schema.minLength) { 170 | bean.constraint += ' minLength: ' + schema.minLength; 171 | } 172 | if (schema.maxLength) { 173 | bean.constraint += ' minLength: ' + schema.maxLength; 174 | } 175 | if (schema.pattern) { 176 | bean.constraint += ' pattern: ' + schema.pattern; 177 | } 178 | return bean; 179 | } 180 | 181 | function fixType(schema, definitions) { 182 | if (schema.type === 'array' && schema.items && schema.items.type) { 183 | return '[' + schema.items.type + ']'; 184 | } 185 | if ($.get(schema, 'schema.type') === 'array' && $.get(schema, 'schema.items.type')) { 186 | return '[' + schema.schema.items.type + ']'; 187 | } 188 | 189 | const schemaKey = getSchemaKey(getSchemaRef(schema)); 190 | if (schema.type === 'array' && schemaKey) { 191 | return '[' + getSchemaType(schemaKey, definitions) + ']'; 192 | } 193 | if ($.get(schema, 'schema.type') === 'array' && schemaKey) { 194 | return '[' + getSchemaType(schemaKey, definitions) + ']'; 195 | } 196 | 197 | if (schemaKey) { 198 | return getSchemaType(schemaKey, definitions); 199 | } 200 | 201 | if ($.get(schema, 'schema.type')) { 202 | return schema.schema.type; 203 | } 204 | return schema.type; 205 | } 206 | 207 | function fixFormat(schema, definitions) { 208 | const format = $.get(schema, 'schema.items.format'); 209 | if (format) { 210 | return format; 211 | } 212 | 213 | const schemaRef = getSchemaRef(schema); 214 | if (schemaRef) { 215 | const schemaKey = getSchemaKey(schemaRef); 216 | const schemaTitle = getSchemaTitle(schemaKey, definitions); 217 | return schemaTitle ? schemaTitle : schemaKey; 218 | } 219 | 220 | return schema.format; 221 | } 222 | 223 | function getSchema(schemaRef, definitions) { 224 | const schemaKey = getSchemaKey(schemaRef); 225 | if (definitions.hasOwnProperty(schemaKey)) { 226 | return definitions[schemaKey]; 227 | } 228 | } 229 | 230 | function getSchemaRef(schema) { 231 | return ( 232 | $.get(schema, '$ref') || 233 | $.get(schema, 'schema.$ref') || 234 | $.get(schema, 'items.$ref') || 235 | $.get(schema, 'schema.items.$ref') 236 | ); 237 | } 238 | 239 | function getSchemaKey(schemaRef) { 240 | const REF = '#/definitions/'; 241 | if (schemaRef && schemaRef.startsWith(REF)) { 242 | return schemaRef.substring(REF.length); 243 | } 244 | } 245 | 246 | function getSchemaType(schemaKey, definitions) { 247 | if (definitions.hasOwnProperty(schemaKey)) { 248 | return definitions[schemaKey].type; 249 | } 250 | // 泛型参数 251 | if ($.endsWith(schemaKey, '«object»')) { 252 | const sk = schemaKey.substring(0, schemaKey.length - '«object»'.length); 253 | return $.get(definitions, [sk, 'type']); 254 | } 255 | } 256 | 257 | function getSchemaTitle(schemaKey, definitions) { 258 | if (definitions.hasOwnProperty(schemaKey)) { 259 | return definitions[schemaKey].title; 260 | } 261 | } 262 | 263 | function isMergeSchema(schema) { 264 | return !!$.get(schema, 'schema.properties') || !!$.get(schema, 'schema.allOf'); 265 | } 266 | 267 | /** 268 | * 创建组合 Schema. 269 | */ 270 | let mergeSchemaIndex = 0; 271 | 272 | function createMergeSchema(schema, definitions) { 273 | const key = '_MergeSchema' + mergeSchemaIndex++; 274 | const mergeSchema = { type: 'object', title: key, properties: {} }; 275 | if ($.isArray($.get(schema, 'schema.allOf'))) { 276 | for (const fragment of schema.schema.allOf) { 277 | if (fragment.hasOwnProperty('$ref')) { 278 | const s = getSchema(fragment['$ref'], definitions); 279 | if (s.properties) { 280 | Object.assign(mergeSchema.properties, s.properties); 281 | } 282 | } 283 | } 284 | } 285 | const properties = $.get(schema, 'schema.properties'); 286 | if (properties) { 287 | $.forOwn(properties, function(value, key) { 288 | if ($.isArray(value.allOf)) { 289 | const propKey = '_MergeSchema' + mergeSchemaIndex++; 290 | const propMergeSchema = { type: 'object', title: propKey, properties: {} }; 291 | for (const fragment of value.allOf) { 292 | if (fragment.hasOwnProperty('$ref')) { 293 | const s = getSchema(fragment['$ref'], definitions); 294 | if (s.properties) { 295 | Object.assign(propMergeSchema.properties, s.properties); 296 | } 297 | } 298 | } 299 | definitions[propKey] = propMergeSchema; 300 | const toMeg = {}; 301 | toMeg[key] = { 302 | description: schema.description, 303 | schema: { 304 | $ref: '#/definitions/' + propKey 305 | } 306 | }; 307 | Object.assign(mergeSchema.properties, toMeg); 308 | } 309 | }); 310 | } 311 | definitions[key] = mergeSchema; 312 | return { 313 | description: schema.description, 314 | schema: { 315 | $ref: '#/definitions/' + key 316 | } 317 | }; 318 | } 319 | 320 | function emptyBean() { 321 | return { 322 | title: '', 323 | type: '', 324 | props: [] 325 | }; 326 | } 327 | 328 | export default { 329 | fixSwaggerJson, 330 | findHttpEntity 331 | }; 332 | -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 74 | 75 | 78 | -------------------------------------------------------------------------------- /src/views/app-layout/HeaderContent.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 44 | -------------------------------------------------------------------------------- /src/views/app-layout/SiderContent.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 63 | -------------------------------------------------------------------------------- /src/views/entity-view/EntityView.vue: -------------------------------------------------------------------------------- 1 | 49 | 69 | 123 | -------------------------------------------------------------------------------- /src/views/entity-view/EntityViewApiInfo.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 65 | -------------------------------------------------------------------------------- /src/views/entity-view/EntityViewBean.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 47 | -------------------------------------------------------------------------------- /src/views/entity-view/EntityViewParam.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 57 | -------------------------------------------------------------------------------- /src/views/entity-view/EntityViewResponse.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/views/entity-view/copiedTagRender.js: -------------------------------------------------------------------------------- 1 | import CopiedTag from '@/components/CopiedTag' 2 | import $ from '@/utils/$' 3 | 4 | export default function copiedTagRender(h, params) { 5 | let subNode = params.row.name || params.row.k2; 6 | if ($.isArray(subNode)) { 7 | subNode = subNode.map(it => { 8 | return h(CopiedTag, { 9 | style: 'margin-right:10px' 10 | }, it) 11 | }); 12 | return h('span', {}, subNode) 13 | } 14 | return h(CopiedTag, {}, subNode); 15 | } 16 | -------------------------------------------------------------------------------- /src/views/entity-view/index.js: -------------------------------------------------------------------------------- 1 | import EntityView from './EntityView' 2 | 3 | export default EntityView 4 | -------------------------------------------------------------------------------- /tests/swagger-resources.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "local json", 4 | "url": "/swagger.json", 5 | "swaggerVersion": "2.0", 6 | "location": "/swagger.json" 7 | }, 8 | { 9 | "name": "petstore swagger", 10 | "url": "https://petstore.swagger.io/v2/swagger.json", 11 | "swaggerVersion": "2.0", 12 | "location": "https://petstore.swagger.io/v2/swagger.json" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /tests/unit/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | jest: true 4 | }, 5 | rules: { 6 | 'import/no-extraneous-dependencies': 'off' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /tests/unit/utils/postman.spec.js: -------------------------------------------------------------------------------- 1 | import swaggerJson from './swagger.json' 2 | import swagger from '@/utils/swagger' 3 | import postman from '@/utils/postman' 4 | 5 | test('exportJson', () => { 6 | const sw = swagger.fixSwaggerJson(swaggerJson); 7 | const postmanJson = postman.exportJson(sw, {basePath: "http://localhost:8080/base"}); 8 | console.log(postmanJson); 9 | }); 10 | 11 | -------------------------------------------------------------------------------- /tests/unit/utils/swagger.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "title": "测试系统 API 文档", 5 | "version": "1.0.0", 6 | "termsOfService": "http://demo.io/terms/", 7 | "description": "description", 8 | "contact": { 9 | "email": "demo@demo.io" 10 | }, 11 | "license": { 12 | "name": "Apache 2.0", 13 | "url": "http://www.apache.org/licenses/LICENSE-2.0.html" 14 | } 15 | }, 16 | "host": "demo.io", 17 | "basePath": "/", 18 | "tags": [ 19 | { 20 | "name": "用户管理", 21 | "description": "User Controller" 22 | }, 23 | { 24 | "name": "项目数据", 25 | "description": "Project Data Controller" 26 | }, 27 | { 28 | "name": "项目管理", 29 | "description": "Project Controller" 30 | } 31 | ], 32 | "paths": { 33 | "/projects": { 34 | "get": { 35 | "tags": ["项目管理"], 36 | "summary": "项目列表", 37 | "operationId": "listUsingGET", 38 | "produces": ["*/*"], 39 | "parameters": [ 40 | { 41 | "name": "page", 42 | "in": "query", 43 | "description": "分页-页码(0起始)", 44 | "required": false, 45 | "type": "integer", 46 | "format": "int32" 47 | }, 48 | { 49 | "name": "size", 50 | "in": "query", 51 | "description": "分页-条数", 52 | "required": false, 53 | "type": "integer", 54 | "format": "int32" 55 | } 56 | ], 57 | "responses": { 58 | "200": { 59 | "description": "OK", 60 | "schema": { 61 | "$ref": "#/definitions/Page«Project»" 62 | } 63 | }, 64 | "400": { 65 | "description": "参数错误" 66 | }, 67 | "401": { 68 | "description": "权限不足" 69 | } 70 | }, 71 | "security": [ 72 | { 73 | "Authorization": ["global"] 74 | } 75 | ], 76 | "deprecated": false 77 | }, 78 | "post": { 79 | "tags": ["项目管理"], 80 | "summary": "创建项目", 81 | "operationId": "createUsingPOST", 82 | "consumes": ["application/json"], 83 | "produces": ["*/*"], 84 | "parameters": [ 85 | { 86 | "in": "body", 87 | "name": "project", 88 | "description": "project", 89 | "required": true, 90 | "schema": { 91 | "$ref": "#/definitions/Project" 92 | } 93 | } 94 | ], 95 | "responses": { 96 | "200": { 97 | "description": "OK" 98 | }, 99 | "400": { 100 | "description": "参数错误" 101 | }, 102 | "401": { 103 | "description": "权限不足" 104 | } 105 | }, 106 | "security": [ 107 | { 108 | "Authorization": ["global"] 109 | } 110 | ], 111 | "deprecated": false 112 | } 113 | }, 114 | "/projects/{projectId}/data": { 115 | "get": { 116 | "tags": ["项目数据"], 117 | "summary": "项目数据列表", 118 | "operationId": "findByProjectIdUsingGET", 119 | "produces": ["*/*"], 120 | "parameters": [ 121 | { 122 | "name": "page", 123 | "in": "query", 124 | "description": "分页-页码(0起始)", 125 | "required": false, 126 | "type": "integer", 127 | "format": "int32" 128 | }, 129 | { 130 | "name": "projectId", 131 | "in": "path", 132 | "description": "projectId", 133 | "required": true, 134 | "type": "string", 135 | "format": "uuid" 136 | }, 137 | { 138 | "name": "size", 139 | "in": "query", 140 | "description": "分页-条数", 141 | "required": false, 142 | "type": "integer", 143 | "format": "int32" 144 | } 145 | ], 146 | "responses": { 147 | "200": { 148 | "description": "OK", 149 | "schema": { 150 | "$ref": "#/definitions/Page«ProjectData»" 151 | } 152 | }, 153 | "400": { 154 | "description": "参数错误" 155 | }, 156 | "401": { 157 | "description": "权限不足" 158 | } 159 | }, 160 | "security": [ 161 | { 162 | "Authorization": ["global"] 163 | } 164 | ], 165 | "deprecated": false 166 | } 167 | }, 168 | "/projects/{projectId}/data/upload": { 169 | "post": { 170 | "tags": ["项目数据"], 171 | "summary": "项目数据上传", 172 | "operationId": "uploadUsingPOST", 173 | "consumes": ["multipart/form-data"], 174 | "produces": ["*/*"], 175 | "parameters": [ 176 | { 177 | "name": "file", 178 | "in": "formData", 179 | "description": "file", 180 | "required": true, 181 | "type": "file" 182 | }, 183 | { 184 | "name": "projectId", 185 | "in": "path", 186 | "description": "projectId", 187 | "required": true, 188 | "type": "string", 189 | "format": "uuid" 190 | } 191 | ], 192 | "responses": { 193 | "200": { 194 | "description": "OK", 195 | "schema": { 196 | "$ref": "#/definitions/ProjectDataUploadInfo" 197 | } 198 | }, 199 | "400": { 200 | "description": "参数错误" 201 | }, 202 | "401": { 203 | "description": "权限不足" 204 | } 205 | }, 206 | "security": [ 207 | { 208 | "Authorization": ["global"] 209 | } 210 | ], 211 | "deprecated": false 212 | } 213 | }, 214 | "/projects/{projectId}/users": { 215 | "get": { 216 | "tags": ["项目管理"], 217 | "summary": "项目用户", 218 | "operationId": "getUsersUsingGET", 219 | "produces": ["*/*"], 220 | "parameters": [ 221 | { 222 | "name": "projectId", 223 | "in": "path", 224 | "description": "projectId", 225 | "required": true, 226 | "type": "string", 227 | "format": "uuid" 228 | } 229 | ], 230 | "responses": { 231 | "200": { 232 | "description": "OK", 233 | "schema": { 234 | "type": "array", 235 | "items": { 236 | "$ref": "#/definitions/用户基本信息" 237 | } 238 | } 239 | }, 240 | "400": { 241 | "description": "参数错误" 242 | }, 243 | "401": { 244 | "description": "权限不足" 245 | } 246 | }, 247 | "security": [ 248 | { 249 | "Authorization": ["global"] 250 | } 251 | ], 252 | "deprecated": false 253 | }, 254 | "put": { 255 | "tags": ["项目管理"], 256 | "summary": "分配用户", 257 | "operationId": "saveUsersUsingPUT", 258 | "consumes": ["application/json"], 259 | "produces": ["*/*"], 260 | "parameters": [ 261 | { 262 | "name": "projectId", 263 | "in": "path", 264 | "description": "projectId", 265 | "required": true, 266 | "type": "string", 267 | "format": "uuid" 268 | }, 269 | { 270 | "in": "body", 271 | "name": "userIds", 272 | "description": "userIds", 273 | "required": true, 274 | "schema": { 275 | "type": "array", 276 | "items": { 277 | "type": "string", 278 | "format": "uuid" 279 | } 280 | } 281 | } 282 | ], 283 | "responses": { 284 | "200": { 285 | "description": "OK" 286 | }, 287 | "400": { 288 | "description": "参数错误" 289 | }, 290 | "401": { 291 | "description": "权限不足" 292 | } 293 | }, 294 | "security": [ 295 | { 296 | "Authorization": ["global"] 297 | } 298 | ], 299 | "deprecated": false 300 | } 301 | }, 302 | "/users": { 303 | "get": { 304 | "tags": ["用户管理"], 305 | "summary": "用户列表", 306 | "operationId": "findAllUsingGET", 307 | "produces": ["*/*"], 308 | "parameters": [ 309 | { 310 | "name": "page", 311 | "in": "query", 312 | "description": "分页-页码(0起始)", 313 | "required": false, 314 | "type": "integer", 315 | "format": "int32" 316 | }, 317 | { 318 | "name": "size", 319 | "in": "query", 320 | "description": "分页-条数", 321 | "required": false, 322 | "type": "integer", 323 | "format": "int32" 324 | } 325 | ], 326 | "responses": { 327 | "200": { 328 | "description": "OK", 329 | "schema": { 330 | "$ref": "#/definitions/Page«用户基本信息»" 331 | } 332 | }, 333 | "400": { 334 | "description": "参数错误" 335 | }, 336 | "401": { 337 | "description": "权限不足" 338 | } 339 | }, 340 | "security": [ 341 | { 342 | "Authorization": ["global"] 343 | } 344 | ], 345 | "deprecated": false 346 | }, 347 | "post": { 348 | "tags": ["用户管理"], 349 | "summary": "创建用户", 350 | "operationId": "createUsingPOST_1", 351 | "consumes": ["application/json"], 352 | "produces": ["*/*"], 353 | "parameters": [ 354 | { 355 | "in": "body", 356 | "name": "userForm", 357 | "description": "userForm", 358 | "required": true, 359 | "schema": { 360 | "$ref": "#/definitions/UserForm" 361 | } 362 | } 363 | ], 364 | "responses": { 365 | "200": { 366 | "description": "OK" 367 | }, 368 | "400": { 369 | "description": "参数错误" 370 | }, 371 | "401": { 372 | "description": "权限不足" 373 | } 374 | }, 375 | "security": [ 376 | { 377 | "Authorization": ["global"] 378 | } 379 | ], 380 | "deprecated": false 381 | } 382 | }, 383 | "/users/me": { 384 | "get": { 385 | "tags": ["用户管理"], 386 | "summary": "当前用户", 387 | "operationId": "meUsingGET", 388 | "produces": ["*/*"], 389 | "responses": { 390 | "200": { 391 | "description": "OK", 392 | "schema": { 393 | "$ref": "#/definitions/用户基本信息" 394 | } 395 | }, 396 | "400": { 397 | "description": "参数错误" 398 | }, 399 | "401": { 400 | "description": "权限不足" 401 | } 402 | }, 403 | "security": [ 404 | { 405 | "Authorization": ["global"] 406 | } 407 | ], 408 | "deprecated": false 409 | } 410 | } 411 | }, 412 | "securityDefinitions": { 413 | "Authorization": { 414 | "type": "apiKey", 415 | "name": "TOKEN", 416 | "in": "header" 417 | } 418 | }, 419 | "definitions": { 420 | "Pageable": { 421 | "type": "object", 422 | "properties": { 423 | "offset": { 424 | "type": "integer", 425 | "format": "int64" 426 | }, 427 | "pageNumber": { 428 | "type": "integer", 429 | "format": "int32" 430 | }, 431 | "pageSize": { 432 | "type": "integer", 433 | "format": "int32" 434 | }, 435 | "paged": { 436 | "type": "boolean" 437 | }, 438 | "sort": { 439 | "$ref": "#/definitions/Sort" 440 | }, 441 | "unpaged": { 442 | "type": "boolean" 443 | } 444 | }, 445 | "title": "Pageable" 446 | }, 447 | "Page«ProjectData»": { 448 | "type": "object", 449 | "properties": { 450 | "content": { 451 | "type": "array", 452 | "description": "分页-内容列表", 453 | "items": { 454 | "$ref": "#/definitions/ProjectData" 455 | } 456 | }, 457 | "number": { 458 | "type": "integer", 459 | "format": "int32", 460 | "description": "分页-页码(0起始)" 461 | }, 462 | "size": { 463 | "type": "integer", 464 | "format": "int32", 465 | "description": "分页-条数" 466 | }, 467 | "totalElements": { 468 | "type": "integer", 469 | "format": "int64", 470 | "description": "分页-总条数" 471 | }, 472 | "totalPages": { 473 | "type": "integer", 474 | "format": "int32", 475 | "description": "分页-总页数" 476 | } 477 | }, 478 | "title": "Page«ProjectData»" 479 | }, 480 | "Page«Project»": { 481 | "type": "object", 482 | "properties": { 483 | "content": { 484 | "type": "array", 485 | "description": "分页-内容列表", 486 | "items": { 487 | "$ref": "#/definitions/Project" 488 | } 489 | }, 490 | "number": { 491 | "type": "integer", 492 | "format": "int32", 493 | "description": "分页-页码(0起始)" 494 | }, 495 | "size": { 496 | "type": "integer", 497 | "format": "int32", 498 | "description": "分页-条数" 499 | }, 500 | "totalElements": { 501 | "type": "integer", 502 | "format": "int64", 503 | "description": "分页-总条数" 504 | }, 505 | "totalPages": { 506 | "type": "integer", 507 | "format": "int32", 508 | "description": "分页-总页数" 509 | } 510 | }, 511 | "title": "Page«Project»" 512 | }, 513 | "Page«用户基本信息»": { 514 | "type": "object", 515 | "properties": { 516 | "content": { 517 | "type": "array", 518 | "description": "分页-内容列表", 519 | "items": { 520 | "$ref": "#/definitions/用户基本信息" 521 | } 522 | }, 523 | "number": { 524 | "type": "integer", 525 | "format": "int32", 526 | "description": "分页-页码(0起始)" 527 | }, 528 | "size": { 529 | "type": "integer", 530 | "format": "int32", 531 | "description": "分页-条数" 532 | }, 533 | "totalElements": { 534 | "type": "integer", 535 | "format": "int64", 536 | "description": "分页-总条数" 537 | }, 538 | "totalPages": { 539 | "type": "integer", 540 | "format": "int32", 541 | "description": "分页-总页数" 542 | } 543 | }, 544 | "title": "Page«用户基本信息»" 545 | }, 546 | "Project": { 547 | "type": "object", 548 | "properties": { 549 | "createdBy": { 550 | "type": "string", 551 | "format": "uuid" 552 | }, 553 | "createdDate": { 554 | "type": "string", 555 | "format": "date-time", 556 | "description": "创建时间" 557 | }, 558 | "id": { 559 | "type": "string", 560 | "format": "uuid" 561 | }, 562 | "name": { 563 | "type": "string", 564 | "description": "项目名称" 565 | }, 566 | "updatedDate": { 567 | "type": "string", 568 | "format": "date-time", 569 | "description": "修改时间" 570 | } 571 | }, 572 | "title": "Project" 573 | }, 574 | "ProjectData": { 575 | "type": "object", 576 | "properties": { 577 | "batch": { 578 | "type": "string" 579 | }, 580 | "createdBy": { 581 | "type": "string", 582 | "format": "uuid" 583 | }, 584 | "createdDate": { 585 | "type": "string", 586 | "format": "date-time", 587 | "description": "创建时间" 588 | }, 589 | "id": { 590 | "type": "string", 591 | "format": "uuid" 592 | }, 593 | "projectId": { 594 | "type": "string", 595 | "format": "uuid" 596 | }, 597 | "updatedDate": { 598 | "type": "string", 599 | "format": "date-time", 600 | "description": "修改时间" 601 | } 602 | }, 603 | "title": "ProjectData" 604 | }, 605 | "UserForm": { 606 | "type": "object", 607 | "properties": { 608 | "password": { 609 | "type": "string", 610 | "description": "密码", 611 | "minLength": 6, 612 | "maxLength": 18 613 | }, 614 | "username": { 615 | "type": "string", 616 | "description": "用户名", 617 | "pattern": "[a-zA-Z][a-zA-Z0-9@_.]{6,18}" 618 | } 619 | }, 620 | "title": "UserForm" 621 | }, 622 | "用户基本信息": { 623 | "type": "object", 624 | "properties": { 625 | "enabled": { 626 | "type": "boolean", 627 | "description": "是否启用" 628 | }, 629 | "id": { 630 | "type": "string", 631 | "format": "uuid" 632 | }, 633 | "username": { 634 | "type": "string", 635 | "description": "用户名", 636 | "pattern": "[a-zA-Z][a-zA-Z0-9@_.]{6,18}" 637 | } 638 | }, 639 | "title": "用户基本信息" 640 | } 641 | } 642 | } 643 | -------------------------------------------------------------------------------- /tests/unit/utils/swagger.spec.js: -------------------------------------------------------------------------------- 1 | import swaggerJson from './swagger.json' 2 | import swagger from '@/utils/swagger' 3 | 4 | test('fixSwaggerJson', () => { 5 | const value = swagger.fixSwaggerJson(swaggerJson); 6 | console.log(JSON.stringify(value)); 7 | }); 8 | 9 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | const swaggerResources = require('./tests/swagger-resources'); 2 | const swaggerJson = require('./tests/unit/utils/swagger.json'); 3 | const CompressionPlugin = require('compression-webpack-plugin'); 4 | 5 | module.exports = { 6 | filenameHashing: false, 7 | productionSourceMap: false, 8 | publicPath: '', 9 | indexPath: 'swagger-ui.html', 10 | assetsDir: 'webjars/swagger-document-ui', 11 | devServer: { 12 | openPage: '/swagger-ui.html', 13 | open: true, 14 | proxy: 'http://swagger-bootstrap-ui.xiaominfo.com', 15 | before: function(app) { 16 | app.get('/swagger-resources.json', function(req, res) { 17 | res.json(swaggerResources); 18 | }); 19 | app.get('/swagger.json', function(req, res) { 20 | res.json(swaggerJson); 21 | }); 22 | } 23 | }, 24 | configureWebpack: () => { 25 | if (process.env.NODE_ENV === 'production') { 26 | return { 27 | plugins: [new CompressionPlugin({ exclude: /\/*.html/ })] 28 | }; 29 | } 30 | } 31 | }; 32 | --------------------------------------------------------------------------------