当前位置:首页 > 编程笔记 > 正文
已解决

API文档自动生成

来自网友在路上 158858提问 提问时间:2023-11-02 12:20:45阅读次数: 58

最佳答案 问答题库588位专家为你答疑解惑

API文档自动生成

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

背景

对于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>

效果图

在这里插入图片描述
在这里插入图片描述

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"API文档自动生成":http://eshow365.cn/6-30155-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!