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

 

posted @ 2021-11-02 10:19  草木物语  阅读(1626)  评论(0编辑  收藏  举报