首页 > 其他分享 >smart-doc生成接口文档

smart-doc生成接口文档

时间:2022-10-18 15:23:39浏览次数:38  
标签:false doc since 文档 true smart

 

 

maven引入插件

 <plugin>
                <groupId>com.github.shalousun</groupId>
                <artifactId>smart-doc-maven-plugin</artifactId>
                <version>2.0.0</version>
                <configuration>
                    <!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
                    <configFile>./src/main/resources/smart-doc.json</configFile>
                    <!--指定项目名称-->
                    <projectName>开发环境</projectName>
                    <!--smart-doc实现自动分析依赖树加载第三方依赖的源码,如果一些框架依赖库加载不到导致报错,这时请使用excludes排除掉-->
                    <!--smart-doc能自动分析依赖树加载所有依赖源码,原则上会影响文档构建效率,因此你可以使用includes来让插件加载你配置的组件-->
                    <includes>
                        <!--格式为:groupId:artifactId;参考如下-->
                        <include>com.alibaba:fastjson</include>
                    </includes>
                </configuration>
                <!-- <executions>
                     <execution>
                         &lt;!&ndash;如果不需要在执行编译时启动smart-doc,则将phase注释掉&ndash;&gt;
                         <phase>compile</phase>
                         <goals>
                             &lt;!&ndash;smart-doc提供了html、openapi、markdown等goal,可按需配置&ndash;&gt;
                             <goal>html</goal>
                         </goals>
                     </execution>
                 </executions>-->
            </plugin>

 

 

smart-doc.json

{
  "serverUrl": "http://ip:port", //设置服务器地址,非必须
  "isStrict": false, //是否开启严格模式
  "allInOne": true,  //是否将文档合并到一个文件中,一般推荐为true
  "outPath": "D://api", //指定文档的输出路径
  "coverOld": true,  //是否覆盖旧的文件,主要用于mardown文件覆盖
  "packageFilters": "",//controller包过滤,多个包用英文逗号隔开
  "createDebugPage": true,//@since 2.0.0 smart-doc支持创建可以测试的html页面,仅在AllInOne模式中起作用。
  "md5EncryptedHtmlName": false,//只有每个controller生成一个html文件是才使用
  "projectName": "接口",//配置自己的项目名称
  "skipTransientField": true,//目前未实现
  "showAuthor":false,//是否显示接口作者名称,默认是true,不想显示可关闭
  "requestFieldToUnderline":false, //自动将驼峰入参字段在文档中转为下划线格式,//@since 1.8.7 版本开始
  "responseFieldToUnderline":false,//自动将驼峰入参字段在文档中转为下划线格式,//@since 1.8.7 版本开始
  "inlineEnum":true,//设置为true会将枚举详情展示到参数表中,默认关闭,//@since 1.8.8版本开始
  "recursionLimit":20,//设置允许递归执行的次数用于避免栈溢出,默认是7,正常为3次以内,//@since 1.8.8版本开始
  "displayActualType":false,//配置true会在注释栏自动显示泛型的真实类型短类名,@since 1.9.6
  "urlSuffix":"",//支持SpringMVC旧项目的url后缀,@since 2.1.0
  "appKey": "2020208",// torna平台对接appKey,, @since 2.0.9
  "appToken": "c16931fa685340fcbfef", //torna平台appToken,@since 2.0.9
  "secret": "[email protected]#V&tUUYZR",
  "ignoreRequestParams":[ //忽略请求参数对象,把不想生成文档的参数对象屏蔽掉,@since 1.9.2
    "javax.servlet.http.HttpSession",
    "javax.servlet.http.HttpServletRequest"
  ]
}

 

 

生成

 

 这会生成html页面接口文档

 

注释方式直接

 

标签:false,doc,since,文档,true,smart
From: https://www.cnblogs.com/pxblog/p/16802648.html

相关文章