title: swagger-ui 3升級(jí)
tags: swagger-ui 3
在上一篇文章swagger入門中土居,我們初步學(xué)習(xí)了swagger的運(yùn)用分别,以及swagger-ui那簡(jiǎn)潔的api文檔界面渤愁,但由于用的swagger-ui的版本是2.7.0的,因此會(huì)有些bug扭倾,比如最大最小值在文檔界面無(wú)法顯示薪缆,界面不夠美觀等等。幸好有swagger-ui更新的版本炬称,解決了上面的一些問(wèn)題汁果,下面我們就在上篇文章工程的基礎(chǔ)上,將swagger-ui進(jìn)行升級(jí).
去除原有依賴
首先將原來(lái)pom文件中的swagger-ui依賴注釋或刪除,像這樣玲躯。(注意:只需將swagger-ui的依賴去掉)
<!--<dependency>-->
<!--<groupId>io.springfox</groupId>-->
<!--<artifactId>springfox-swagger-ui</artifactId>-->
<!--<version>2.7.0</version>-->
<!--</dependency>-->
下載新的swagger-ui文件
到swagger-ui的github上下載zip包据德,然后解壓,將dist這個(gè)文件夾下的所有文件拷貝到你工程里:
修改index.html
將其中的url更改為你對(duì)應(yīng)的api文檔數(shù)據(jù)來(lái)源的地址:
window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: "http://localhost:8000/v2/api-docs",//need to be modify
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
修改完成后跷车,啟動(dòng)你的應(yīng)用棘利,不出意外的話,你將會(huì)看到一個(gè)精美的(起碼我是這么認(rèn)為的)api文檔界面:
看是不是比上一版本的更好看了.