栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java > SpringBoot

SpringCloud 自动生成API文档

SpringBoot 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringCloud 自动生成API文档

使用说明

克隆项目下来

git clone https://github.com/dounine/japi.git

编译打包

cd japi/java
gradle install -xtest

运行JAPI后台管理

cd japi/java
gradle bootRun

运行JAPI文档界面

cd japi/node
node app.js
生成RESTFul文档

maven项目


    com.dounine.japi
    client
    1.0

gradle项目

compile group: 'com.dounine.japi', name: 'client', version: '1.0'

编辑resources/japi.properties配置文件

japi.name=test
japi.uuid=43a600877430438596de3d330e4bd06e
japi.version=1.0.0japi.author=lake
japi.url=http://192.168.0.123:8080japi.description=this is project description.
japi.createTime=2017-02-23 10:44:44japi.icon=/home/lake/github/japi/html/img/logo.png
japi.server=http://192.168.0.179:7778japi.server.username=japi
japi.server.password=japi123

编写一个action

@GetMapping(value = "v2/list")public Result hots(@Validated({User.UserDEL.class}) User user) throws RuntimeException {    return null;
}

编写一个API生成类
JapiCreateTest.java

@Test
    public void testCreate(){
        JapiClient.setPrefixPath("/home/lake/github/test-japi/java/");//项目路径前缀
        JapiClient.setpostfixPath("/src/main/java");//项目路径后缀

        JapiClient.setProjectJavaPath("client");//主项目地扯
        JapiClient.setActionReletivePath("com/dounine/test-japi/action");//相对主项目action包所在路径
        //JapiClient.setIncludeProjectJavaPath(new String[]{"api"});//主项目中关联的其它项目包路径
        JapiClient.setIncludePackages(new String[]{"com.dounine.test-japi"});//关联的包,用于准确快速搜索
        JapiClient.saveHistory(true);//是否保留本地历史版本
        JapiClient.setFlushServer(false);//强制同步本地与服务器所有的版本(会先删除服务器以前的历史版本)

        IProject project = ProjectImpl.init();
        JapiClientStorage japiClientStorage = JapiClientStorage.getInstance();
        japiClientStorage.setProject(project);
        japiClientStorage.autoSaveToDisk();//自动使用到本地磁盘==> 用户目录/.japi-client/
        new JapiClientTransfer().autoTransfer(japiClientStorage);//文件传输到主服务器.
    }
最后访问浏览器 http://localhost:7777

就可看到RESTFul文档登录


登录界面


使用自己的帐号登录就可以看到所有项目


模块列表


进入项目看详细RESTFul接口

模块接口

使用场景

JAPI最适合在SpringCloud这样的分布式多模块项目中使用,内置强大的正则表达式,这会让代码注释更加规范,区别于Swigger这类使用侵入式注解生成文档的,JAPI是完全基于标准注释生成的,支持强大的JSR303或者是自定义注解。

开源精神

欢迎有意向的同学加入JAPI开源项目并将它改造得更好。



作者:dounine
链接:https://www.jianshu.com/p/0d3b0c578c73


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/235068.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号