diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3365e4f5566a5c14be116f5b04fafe0142b55af3 --- /dev/null +++ b/README.md @@ -0,0 +1,127 @@ +**smart-doc**是一个java restful api文档生成工具,smart-doc颠覆了传统类似swagger这种大量采用注解侵入来生成文档的实现方法。smart-doc完全基于接口源码分析来生成接口文档,完全做到零注解侵入,**只需要按照java标准注释的写就能得到一个标准的markdown接口文档**。如果你已经厌倦了swagger等文档工具的注解和强侵入污染,那请拥抱smart-doc吧!目前smart-doc正在完善中。。。 +添加依赖 +```xml + + com.github.shalousun + smart-doc + 1.1 + test + +``` +//严格模式下,会检测javadoc,如过没写注释会抛出异常 +```java +/** + * hello + * + * @author dujf + * @date 2018/8/31 + * @since JDK1.8 + */ +@RestController +@RequestMapping("/hello") +public class HelloController { + + /** + * 创建 + * + * @param user + * @return + */ + @PostMapping + public User create(User user) { + return user; + } + + /** + * 查询 + * + * @param name 用户名 + * @return + */ + @GetMapping + public User getName(String name) { + return new User(); + } + + /** + * 修改 + * + * @param name + * @return + */ + @PutMapping + public String update(String name) { + return name; + } + + /** + * 删除 + * + * @param name + * @return + */ + @DeleteMapping + public String delete(String name) { + return name; + } +} + +/** + * 用户表 + * @author dujf + * @date 2018/8/31 + * @since JDK1.8 + */ +public class User { + + /** + * 姓名 + */ + @NotNull//有此注解生成文档require = true + private String name; + + /** + * 电话 + */ + private String mobile; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } +} +``` +```java +/** + * 测试生成文档 + */ + @Test + public void testBuilderControllersApiSimple() { + ApiConfig config = new ApiConfig(); + //服务地址 + config.setServerUrl("http://localhost:8010"); + //生成到一个文档 + config.setAllInOne(true); + //采用严格模式 + config.isStrict(); + //文档输出路径 + config.setOutPath("/Users/dujf/Downloads/md"); + ApiDocBuilder.builderControllersApi(config); + //将生成的文档输出到/Users/dujf/Downloads/md目录下,严格模式下api-doc会检测Controller的接口注释 + } +``` +生成文档示例: +![image.png](https://upload-images.jianshu.io/upload_images/11748913-ec01faa2c7654cac.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) + +参考链接:https://github.com/shalousun/ApplicationPower/tree/master/smart-doc \ No newline at end of file diff --git a/docs/AllInOne.md b/docs/AllInOne.md new file mode 100644 index 0000000000000000000000000000000000000000..245423ed1ee7ca62e90ff55a01474bc428a3156d --- /dev/null +++ b/docs/AllInOne.md @@ -0,0 +1,734 @@ +# hello +## 创建 +**URL:** http://localhost:8010/hello/ + +**Type:** post + +**Content-Type:** application/x-www-form-urlencoded + + +**Request-parameters:** + +Parameter | Type|Description|Required +---|---|---|--- +id|int|id|false +account|string|账号|true +password|string|密码|false + + +**Request-example:** +``` +smart-doc currently cannot provide examples of parameters for the RequestParam request mode. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +id|int|id +account|string|账号 +password|string|密码 + + +**Response-example:** +``` +{ + "id":931, + "account":"ki5nxd", + "password":"22ad55" +} +``` + +## 查询 +**URL:** http://localhost:8010/hello/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + +**Request-parameters:** + +Parameter | Type|Description|Required +---|---|---|--- +name|string|No comments found.|true + + +**Request-example:** +``` +smart-doc currently cannot provide examples of parameters for the RequestParam request mode. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +id|int|id +account|string|账号 +password|string|密码 + + +**Response-example:** +``` +{ + "id":303, + "account":"wsm356", + "password":"8ay4qc" +} +``` + +# +## +**URL:** http://localhost:8010/redis/string/ + +**Type:** post + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +## +**URL:** http://localhost:8010/redis/string/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +# +## redis 操作list +**URL:** http://localhost:8010/redis/list/ + +**Type:** post + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +## redis 操作list +**URL:** http://localhost:8010/redis/list/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +# +## 添加 +**URL:** http://localhost:8010/redis/hash/ + +**Type:** post + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +## 查询 +**URL:** http://localhost:8010/redis/hash/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +# +## redis 操作list +**URL:** http://localhost:8010/redis/zset/ + +**Type:** post + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +## redis 操作list +**URL:** http://localhost:8010/redis/zset/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +# 资源 +## 创建 +**URL:** http://localhost:8010/re/ + +**Type:** post + +**Content-Type:** application/x-www-form-urlencoded + + +**Request-parameters:** + +Parameter | Type|Description|Required +---|---|---|--- +name|string|用户名|true + + +**Request-example:** +``` +smart-doc currently cannot provide examples of parameters for the RequestParam request mode. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +no param name|string|The interface directly returns the string type value. + + +**Response-example:** +``` +"n8olwl" +``` + +## 查询 +**URL:** http://localhost:8010/re/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + +**Request-parameters:** + +Parameter | Type|Description|Required +---|---|---|--- +name|string|No comments found.|true + + +**Request-example:** +``` +smart-doc currently cannot provide examples of parameters for the RequestParam request mode. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +no param name|string|The interface directly returns the string type value. + + +**Response-example:** +``` +"3ubg2j" +``` + +# +## +**URL:** http://localhost:8010/grap/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +name|string|No comments found. +description|string|No comments found. +fieldDefinitionsByName|map|No comments found. +└─any object|object|any object +interfaces|array|No comments found. +definition|object|No comments found. +└─sourceLocation|object|No comments found. +     └─line|int|No comments found. +     └─column|int|No comments found. +└─comments|array|No comments found. +└─name|string|No comments found. +└─implementz|array|No comments found. +└─directives|array|No comments found. +└─fieldDefinitions|array|No comments found. + + +**Response-example:** +``` +{ + "name":"胤祥.冯", + "description":"oiwu2s", + "fieldDefinitionsByName":{ + "mapKey":{ + + } + }, + "interfaces":{ + "object":"any object" + }, + "definition":{ + "sourceLocation":{ + "line":226, + "column":296 + }, + "comments":{ + "object":"any object" + }, + "name":"胤祥.冯", + "implementz":{ + "object":"any object" + }, + "directives":{ + "object":"any object" + }, + "fieldDefinitions":{ + "object":"any object" + } + } +} +``` + +## +**URL:** http://localhost:8010/grap/simple + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +name|string|No comments found. +description|string|No comments found. +fieldDefinitionsByName|map|No comments found. +└─any object|object|any object +interfaces|array|No comments found. +definition|object|No comments found. +└─sourceLocation|object|No comments found. +     └─line|int|No comments found. +     └─column|int|No comments found. +└─comments|array|No comments found. +└─name|string|No comments found. +└─implementz|array|No comments found. +└─directives|array|No comments found. +└─fieldDefinitions|array|No comments found. + + +**Response-example:** +``` +{ + "name":"胤祥.冯", + "description":"20hkwl", + "fieldDefinitionsByName":{ + "mapKey":{ + + } + }, + "interfaces":{ + "object":"any object" + }, + "definition":{ + "sourceLocation":{ + "line":904, + "column":559 + }, + "comments":{ + "object":"any object" + }, + "name":"胤祥.冯", + "implementz":{ + "object":"any object" + }, + "directives":{ + "object":"any object" + }, + "fieldDefinitions":{ + "object":"any object" + } + } +} +``` + +## +**URL:** http://localhost:8010/grap/union + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +name|string|No comments found. +description|string|No comments found. +types|array|No comments found. +typeResolver|object|No comments found. +definition|object|No comments found. +└─sourceLocation|object|No comments found. +     └─line|int|No comments found. +     └─column|int|No comments found. +└─comments|array|No comments found. +└─name|string|No comments found. +└─directives|array|No comments found. +└─memberTypes|array|No comments found. + + +**Response-example:** +``` +{ + "name":"胤祥.冯", + "description":"vqbnqw", + "types":{ + "object":"any object" + }, + "typeResolver":{ + + }, + "definition":{ + "sourceLocation":{ + "line":96, + "column":387 + }, + "comments":{ + "object":"any object" + }, + "name":"胤祥.冯", + "directives":{ + "object":"any object" + }, + "memberTypes":{ + "object":"any object" + } + } +} +``` + +## +**URL:** http://localhost:8010/grap/enum + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +name|string|No comments found. +description|string|No comments found. +valueDefinitionMap|map|No comments found. +└─any object|object|any object +definition|object|No comments found. +└─sourceLocation|object|No comments found. +     └─line|int|No comments found. +     └─column|int|No comments found. +└─comments|array|No comments found. +└─name|string|No comments found. +└─enumValueDefinitions|array|No comments found. +└─directives|array|No comments found. +coercing|object|No comments found. + + +**Response-example:** +``` +{ + "name":"胤祥.冯", + "description":"xr84lf", + "valueDefinitionMap":{ + "mapKey":{ + + } + }, + "definition":{ + "sourceLocation":{ + "line":738, + "column":522 + }, + "comments":{ + "object":"any object" + }, + "name":"胤祥.冯", + "enumValueDefinitions":{ + "object":"any object" + }, + "directives":{ + "object":"any object" + } + }, + "coercing":{ + + } +} +``` + +# +## 创建用户 +**URL:** http://localhost:8010/graphql/user/ + +**Type:** post + +**Content-Type:** application/json; charset=utf-8 + + +**Request-parameters:** + +Parameter | Type|Description|Required +---|---|---|--- +account|string|账号|false +password|string|密码|false + + +**Request-example:** +``` +{ + "account":"z4vktb", + "password":"n7rkqs" +} +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +id|int|id +account|string|账号 +password|string|密码 + + +**Response-example:** +``` +{ + "id":217, + "account":"e65f6a", + "password":"kmkcrm" +} +``` + +## user列表 +**URL:** http://localhost:8010/graphql/user/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +id|int|id +account|string|账号 +password|string|密码 + + +**Response-example:** +``` +[ + { + "id":148, + "account":"ay1bn3", + "password":"t5vies" + } +] +``` + +## id 查询用户 +**URL:** http://localhost:8010/graphql/user/{id} + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + +**Request-parameters:** + +Parameter | Type|Description|Required +---|---|---|--- +id|number|No comments found.|true + + +**Request-example:** +``` +smart-doc currently cannot provide examples of parameters for the RequestParam request mode. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +id|int|id +account|string|账号 +password|string|密码 + + +**Response-example:** +``` +{ + "id":918, + "account":"z744p8", + "password":"d1x6e7" +} +``` + +## 用户总数 +**URL:** http://localhost:8010/graphql/user/count + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` +**Response-fields:** + +Field | Type|Description +---|---|--- +no param name|number|The interface directly returns the number type value. + + +**Response-example:** +``` +998 +``` + +# +## redis 操作list +**URL:** http://localhost:8010/redis/set/ + +**Type:** post + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` + +## redis 操作list +**URL:** http://localhost:8010/redis/set/ + +**Type:** get + +**Content-Type:** application/x-www-form-urlencoded + + + +**Request-example:** +``` +No request parameters are required. +``` + +**Response-example:** +``` +this api return nothing. +``` +