API文档自动生成

API文档自动生成

背景

对于API接口文档自动生成,可能大家,最新想到的是用swagger,但是有以下问题:

  • 对代码侵入太强
  • 版本升级,并不兼容
  • 不能生成各种类型的文档
    所以,今天给大家推荐一种新的框架smart-doc
    官网文档:https://smart-doc-group.github.io/#/zh-cn/expand

smart-doc

在这里插入图片描述

配置

在这里插入图片描述

smart-doc.json

{
  "serverUrl": "http://localhost:${server.port}",
  "pathPrefix": "",
  "allInOne": true,
  "outPath": "src/main/resources/static/doc",
  "style": "xt256",
  "createDebugPage": true,
  "revisionLogs": [
    {
      "version": "1.0",
      "revisionTime": "2023-09-13",
      "status": "创建",
      "author": "gz",
      "remarks": "jelly接口文档"
    },
    {
      "version": "2.0",
      "revisionTime": "2023-10-13",
      "status": "创建",
      "author": "gd",
      "remarks": "jelly接口文档"
    }
  ],
  "groups": [
    {
      "name": "测试分组1",
      "apis": "com.gz.jelly.security.controller.TestController.*"
    },
    {
      "name": "测试分组2",
      "apis": "com.gz.jelly.security.controller.TwoController.*"
    }
  ],
  "requestHeaders": [
    {
      "name": "token",
      "type": "string",
      "desc": "desc",
      "value": "kk",
      "required": false,
      "since": "-",
      "pathPatterns": "/two/**",
      "excludePathPatterns": "/app/login"
    }
  ]
}
 <plugin>
                <groupId>com.ly.smart-doc</groupId>
                <artifactId>smart-doc-maven-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <configFile>./src/main/resources/smart-doc.json</configFile>
                    <projectName>${project.description}</projectName>
                    <includes>
                        <!-- 使用了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>
                        <!-- 使用了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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我叫果冻

你的鼓励将是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值