Swagger在線文檔美化_進階_微服務_網關整合版_v1.0.0

文件名稱 版本號 作者 qq 版本
Swagger在線文檔美化_進階_微服務_網關整合版 v1.0.0 學生宮布 8416837 knife4j RELEASE
Swagger 2.9.2
SpringBoot 2.2.6
SpringCloud Hoxton.SR4

成功的美化配置 O(∩_∩)O~↓

使用knife4j文檔框架 先看看效果

  • 訪問地址是:http://localhost:8080/doc.html
  • http://localhost:8080是整合微服務的模塊的地址,一般用網關整合
  • 新的UI,和原版樣式不一樣了,好像功能也多了,因爲Swagger的原理是提供後臺數據,頁面進行渲染,因此只要調Swagger的功能接口(http://localhost:8080/微服務路由/v2/api-docs),即可獲得數據。
    在這裏插入圖片描述

有靚麗的外表,且功能也挺好

測試接口試一下 成功

在這裏插入圖片描述

還有下載MD文檔等功能
配置步驟 很簡單

1)分別在網關和其它微服務引入xml依賴:

  • 在網關引入
<!--        knife4j Swagger-ui 美化-->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-micro-spring-boot-starter</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-spring-boot-starter</artifactId>
            <version>RELEASE</version>
        </dependency>
  • 在其它微服務引入:
		<!--        Swagger 美化-->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-micro-spring-boot-starter</artifactId>
            <version>RELEASE</version>
        </dependency>

2)啓動項目成功。訪問:http://localhost:8080/doc.html

其它美化配置

網關聚合微服務Swagger在線文檔

配置步驟 節選
  • 在網關引入Maven依賴xml
		<dependency>
            <groupId>com.github.caspar-chen</groupId>
            <artifactId>swagger-ui-layer</artifactId>
            <version>0.0.2</version>
        </dependency>

版本號:0.0.2,說明很年輕呀

問題

對於微服務來說,接口路由有誤,缺少了添加模塊的路由路徑

訪問頁面不同了,是獨立的新頁面:http://localhost:8080/docs.html
原頁面是:http://localhost:8080/swagger-ui.html
原頁面整合了網關同註冊中心下面的微服務:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章