best2018的gravatar头像
best2018 2023-07-14 10:50:13

springboot集成smart-doc插件,一键生成代码接口API文档

项目描述

springboot集成smart-doc插件,一键生成html、markdown、adoc等多种文件类型的代码API接口文档。

对现有项目代码无侵入,支持javadoc,随时可以生成最新的代码文档,简单好用!

运行环境

jdk8,17+IntelliJ IDEA+maven

项目技术(必填)

springboot+smart-doc插件

数据库文件(可选)

依赖包文件(可选)

资源包文件(可选)

运行视频(可选)

是否原创(转载必填原文地址)

原创

项目截图(必填)

springboot集成smart-doc插件,一键生成代码接口API文档

springboot集成smart-doc插件,一键生成代码接口API文档springboot集成smart-doc插件,一键生成代码接口API文档

运行截图(必填)

简单三步生成现有代码API接口文档

1)pom中配置smart-doc插件配置,详见项目pom文档

2)resources目录下新建smart-doc.json文件,配置生成文档输出地址

3)打开IDEA maven视图,选择smart-doc插件,右键执行即可生成相关API接口文档

springboot集成smart-doc插件,一键生成代码接口API文档

springboot集成smart-doc插件,一键生成代码接口API文档springboot集成smart-doc插件,一键生成代码接口API文档springboot集成smart-doc插件,一键生成代码接口API文档

springboot集成smart-doc插件,一键生成代码接口API文档

curl -X GET -i http://localhost:8080/hello/nono/zuidaima

springboot集成smart-doc插件,一键生成代码接口API文档

注意事项(可选)

1. 本地如果没有java 17,需要修改spring-boot-starter-parent的版本

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.14</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

2.需要添加serverUrl参数,修改smart-doc.json配置文件即可

{
  "serverUrl": "http://localhost:8080",
  "outPath": "D://smart-doc"
}

其他配置项请参考https://smart-doc-group.github.io/#/zh-cn/diy/config

3.HelloController.java代码有问题,修改为如下:

package com.simon.springbootsmartdoc.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author simon
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @RequestMapping("/nono/{nono}")
    public String nono(@PathVariable(name = "nono") String nono) {
        return "Hello " + nono + "!";
    }

    @RequestMapping("/index")
    public String index() {
        return "Hello World!";
    }
}

打赏

已有1人打赏

最代码官方的gravatar头像

文件名:springboot-smartdoc.zip,文件大小:65.755K 下载
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友