smart-doc API文檔生成工具


smart-doc是一款API文檔生成工具,無需多余操作,只要你規范地寫好代碼注釋,就能生成API文檔。同時能直接生成Postman調試文件,一鍵導入Postman即可調試!

 

在項目中添加smart-doc的Maven插件

<plugin>
    <groupId>com.github.shalousun</groupId>
    <artifactId>smart-doc-maven-plugin</artifactId>
    <version>2.2.8</version>
    <configuration>
        <!--指定smart-doc使用的配置文件路徑-->
        <configFile>./src/main/resources/smart-doc.json</configFile>
        <!--指定項目名稱-->
        <projectName>xc-springboot-smart-doc</projectName>
    </configuration>
</plugin>

在項目的resources目錄下,添加配置文件smart-doc.json

{
  "serverUrl": "http://localhost:8081",//指定后端服務訪問地址
  "outPath": "src/main/resources/static/smart-doc",//指定文檔的輸出路徑,生成到項目靜態文件目錄下,隨項目啟動可以查看
  "isStrict": false,//是否開啟嚴格模式
  "allInOne": true,//是否將文檔合並到一個文件中
  "createDebugPage": false,//是否創建可以測試的html頁面
  "packageFilters": "com.xc.xcspringboot.controller.*", //controller包過濾
  "style": "xt256",//基於highlight.js的代碼高設置
  "projectName": "xc-springboot-smart-doc",//配置自己的項目名稱
  "showAuthor": false,//是否顯示接口作者名稱
  "allInOneDocFileName": "index.html"//自定義設置輸出文檔名稱
}

 

打開IDEA的Maven面板,雙擊smart-doc插件的smart-doc:html按鈕,即可生成API文檔

 

 

 運行項目,訪問生成的API接口文檔,包括了請求參數和響應結果的各種說明,訪問地址:http://localhost:8081/smart-doc/index.html

 

官方文檔:https://gitee.com/smart-doc-team/smart-doc/wikis/HOME

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM