SpringBoot 自动生成API文档
2017-04-23 18:11
1021 查看
大家在写后台的时候,如果项目是前后分离的,大家一定会和前端或者是移动端对接接口,那么问题来了,接口是不是要自己写给他们看,一般的会采用Excel或者Word来写,高级一点的就采用API管理平台手工录入,一个项目有上千上万个接口,天啊,这是多么大的工作量,在接口维护的时候更加痛苦,为了解决这样的事我们可以借助 japi 这个项目来完成RESTFul文档的自动生成,完全基于注释生成,更多详细配置可查看https://github.com/dounine/japi。
使用说明
克隆项目下来git clone https://github.com/dounine/japi.git[/code]
编译打包cd japi/java gradle install -xtest运行JAPI后台管理
cd japi/java gradle bootRun运行JAPI文档界面
cd japi/node node app.js生成RESTFul文档
maven项目<dependency> <groupId>com.dounine.japi</groupId> <artifactId>client</artifactId> <version>1.0</version> </dependency>
gradle项目compile group: 'com.dounine.japi', name: 'client', version: '1.0'
编写配置文件
resources/japi.propertiesjapi.name=test japi.uuid=43a600877430438596de3d330e4bd06e japi.version=1.0.0 japi.author=lake japi.url=http://192.168.0.123:8080 japi.description=this is project description. japi.createTime=2017-02-23 10:44:44 japi.icon=/home/lake/github/japi/html/img/logo.png japi.server=http://192.168.0.179:7778 japi.server.username=japi japi.server.password=japi123
编写一个action/** * 获取用户列表 * @param user 用户信息 * @return class User * @version v2 */ @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接口
相关文章推荐
- Spring Boot如何让Web API自动生成文档,并解决swagger-annotations的API注解description属性废弃的问题
- SwaggerUI自动生成API文档(SwaggerUI+SpringBoot)
- Spring boot结合swagger自动生成api文档
- springboot结合swagger自动生成接口文档
- spring boot 中使用swagger 来自动生成接口文档
- SpringCloud SpringBoot mybatis 分布式微服务(二十三)Restdoc生成api文档
- spring-boot整合swagger生成在线api文档
- spring boot rest接口自动生成文档(包含swagger)
- 使用 SpringBoot + Swagger 生成接口 API 文档
- Spring Boot(九)Swagger2自动生成接口文档和Mock模拟数据
- Spring Boot 使用Swagger2自动生成RESTful API文档
- Springboot | SpringBoot 微服务整合Swagger生成API文档
- SpringBoot&Swagger构建REST API并生成API文档
- 使用Spring Boot&Swagger快速构建REST API并生成优美的API文档
- Swagger自动接口文档生成框架————springboot整合swagger总结
- SpringBoot:番外篇SpringBoot+Swagger生成可视图的API文档
- SpringCloud SpringBoot mybatis 分布式微服务(二十九)Restdoc生成api文档
- SpringBoot + mybatis + Swagger快速构建REST API并生成优美的API文档
- Swagger2 生成 Spring Boot API 文档
- Swagger2 生成 Spring Boot API 文档