声明:感谢大神文档贡献,参考大神分享博文。自己集成,备以后用;
smart-doc 使用场景:生成API文档 ,注:文档在线接口调试尚未研究明白
生成文档依据:注释、声明,如:类注释
方法注释
第一步:pom 文件中引入 smart-doc 插件
<!-- smart doc -->
<plugin>
<groupId>com.github.shalousun</groupId>
<artifactId>smart-doc-maven-plugin</artifactId>
<version>2.2.8</version>
<configuration>
<!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
<configFile>./src/main/resources/smart-doc.json</configFile>
</configuration>
<executions>
<execution>
<!--如果不需要在执行编译时启动smart-doc,则将phase注释掉-->
<phase>compile</phase>
<goals>
<!--smart-doc提供了html、openapi、markdown等goal,可按需配置-->
<goal>html</goal>
</goals>
</execution>
</executions>
</plugin>
第二步: src/resource/ 目录下增加 smart-doc.json 配置文件
{
"outPath": "D://smartdoc", //指定文档的输出路径
"serverUrl": "http://192.168.124.122:8066/wjz", //服务器地址,非必须。导出postman建议设置成http://{{server}}方便直接在postman直接设置环境变量
"isStrict": false, //是否开启严格模式
"allInOne": true, //是否将文档合并到一个文件中,一般推荐为true
"coverOld": true, //是否覆盖旧的文件,主要用于mardown文件覆盖
"createDebugPage": true,//@since 2.0.0 smart-doc支持创建可以测试的html页面,仅在AllInOne模式中起作用。
"packageFilters": "com.cdsn.cst.controller.*",//controller包过滤,多个包用英文逗号隔开,2.2.2开始需要采用正则:com.test.controller.*
"style":"xt256", //基于highlight.js的代码高设置,可选值很多可查看码云wiki,喜欢配色统一简洁的同学可以不设置
"projectName": "危急值接口文档"//配置自己的项目名称
}
第三步:使用 maven 插件命令生成 接口文档
第四步:访问/查看 本地 smart-doc 生成的接口文档 debug-all.html