设计文档自动化之smart-doc自动生成接口文档

  • smart-doc 可选配置
    参考:https://smart-doc-group.github.io/#/zh-cn/diy/config

1.安装IDEA插件(更为方便)
在这里插入图片描述
2./src/main/resources/目录下 创建 smart-doc.json
如:(更多配置参考官方文档:https://smart-doc-group.github.io/#/zh-cn/diy/config)

{
  "projectName": "项目设计文档名",
  "serverUrl": "",
  "pathPrefix": "",
  "isStrict": false,
  "allInOne": true,
  "outPath": "生成路径",
  "coverOld": true,
  "createDebugPage": true,
  "packageFilters": "",
  "md5EncryptedHtmlName": false,
  "style":"xt256",
  "skipTransientField": true,
  "sortByTitle":false,
  "showAuthor":false,
  "packageExcludeFilters": "",
  "inlineEnum":true,
  "requestExample":"false",
  "responseExample":"false",
  "showAuthor": false,
  "revisionLogs": [
    {
      "version": "1.0",
      "status": "更新中...",
      "Description": "版本描述"
    }
  ],

  "sourceCodePaths": [
    {
      "path": "src/main/java",
      "desc": "描述"
    }
  ]
}
  1. 在启动模块的pom.xml文件中添加插件配置
<plugin>
    <groupId>com.github.shalousun</groupId>
    <artifactId>smart-doc-maven-plugin</artifactId>
    <version>[最新版本]</version>
    <configuration>
        <!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
        <configFile>./src/main/resources/smart-doc.json</configFile>
        <!--指定项目名称-->
        <projectName>测试</projectName>
        <!--smart-doc实现自动分析依赖树加载第三方依赖的源码,如果一些框架依赖库加载不到导致报错,这时请使用excludes排除掉-->
        <excludes>
            <!--格式为:groupId:artifactId;参考如下-->
            <!--也可以支持正则式如:com.alibaba:.* -->
            <exclude>com.alibaba:fastjson</exclude>
        </excludes>
        <!--includes配置用于配置加载外部依赖源码,配置后插件会按照配置项加载外部源代码而不是自动加载所有,因此使用时需要注意-->
        <!--smart-doc能自动分析依赖树加载所有依赖源码,原则上会影响文档构建效率,因此你可以使用includes来让插件加载你配置的组件-->
        <includes>
            <!--格式为:groupId:artifactId;参考如下-->
            <!--也可以支持正则式如:com.alibaba:.* -->
            <!-- 使用了mybatis-plus的Page分页需要include所使用的源码包 -->
            <include>com.baomidou:mybatis-plus-extension</include>
            <!-- 使用了mybatis-plus的IPage分页需要include mybatis-plus-core-->
            <include>com.baomidou:mybatis-plus-core</include>
            <!-- 如果配置了includes的情况下, 使用了jpa的分页需要include所使用的源码包 -->
            <include>org.springframework.data:spring-data-commons</include>
        </includes>
    </configuration>
    <executions>
        <execution>
            <!--如果不需要在执行编译时启动smart-doc,则将phase注释掉-->
            <phase>compile</phase>
            <goals>
                <!--smart-doc提供了html、openapi、markdown等goal,可按需配置-->
                <goal>html</goal>
            </goals>
        </execution>
    </executions>
</plugin>
  1. 选择生成文件格式,等待在.json文件指定路径下的文件生成
  2. 在这里插入图片描述
  3. 若是生成的md文件,转word报错,可先转成pdf格式再转成doc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值