springboot docapi集成

要使用apidoc就得先安装nodejs,安装nodejs后就可以使用npm安装apidoc了。自行百度安装方法!

apidoc.json

{
  "name": "api文档",
  "version": "1.0.0",
  "title": "接口文档",
  "url": "",
  "sampleUrl": "http://192.168.1.1:8080/xxx",
  "template": {
    "forceLanguage": "zh-cn"
  },
  "template": {
    "withCompare": true,
    "withGenerator": true
  },
  "template": {
    "jQueryAjaxSetup": {
      "contentType": "application/json"
    }
  }
}

注意:这个文件要放在pom.xml同级目录下。

pom.xml引入maven插件

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>exec-npm-run-apidoc</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <!-- 不同电脑位置可能不一样 -->
                    <executable>C:\Users\Yida\AppData\Roaming\npm\apidoc.cmd</executable>
                            <arguments>
                                <argument>-f</argument>
                                <argument>".*\.java$"</argument>
                                <argument>-i</argument>
                                <argument>${basedir}</argument>
                                <argument>-o</argument>
                                <!-- 生成后存放的地址 -->
                                <argument>${basedir}/src/main/resources/apidoc</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

然后就开撸了

可以写在方法上,也可以全写在一起。 大家随意!

  /**
     * @api {get} /allUser 获取所有用户
     * @apiGroup user
     * @apiDescription 获取所有用户
     * @apiParam {int} code 这儿是参数介绍
     * @apiParamExample {json} Request-Example:
     * {
     *     code: 123455
     * }
     * @apiSuccess {boolean} data 
     */

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值