API文档自动生成

API文档自动生成

  • 背景
  • smart-doc
  • 配置
  • 效果图

背景

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

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

smart-doc

API文档自动生成_第1张图片

配置

API文档自动生成_第2张图片

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-docgroupId>
                <artifactId>smart-doc-maven-pluginartifactId>
                <version>3.0.0version>
                <configuration>
                    <configFile>./src/main/resources/smart-doc.jsonconfigFile>
                    <projectName>${project.description}projectName>
                    <includes>
                        
                        <include>com.baomidou:mybatis-plus-extensioninclude>
                        
                        <include>com.baomidou:mybatis-plus-coreinclude>
                        
                        <include>org.springframework.data:spring-data-commonsinclude>
                    includes>
                configuration>
                <executions>
                    <execution>
                        
                        <phase>compilephase>
                        <goals>
                            
                            <goal>htmlgoal>
                        goals>
                    execution>
                executions>
            plugin>

效果图

API文档自动生成_第3张图片
API文档自动生成_第4张图片

你可能感兴趣的:(微服务解决方案,java)