diff --git a/CHANGELOG.md b/CHANGELOG.md index fa8a8cba..3770aa36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ 5. 修复父类是泛型时父类中LocalDateTime类型字段生成json样例错误。 6. 添加将接口排序order推送到torna中。 7. 修复类上的@ignore tag不生效bug. + 8. 优化字典码推送,空字典码不会像torna发起推送请求。 #### 版本号:2.1.8 - 更新日期: 2020-05-22 diff --git a/README_CN.md b/README_CN.md index efb81ea9..91c32bb6 100644 --- a/README_CN.md +++ b/README_CN.md @@ -76,7 +76,7 @@ smart-doc官方目前已经开发完成[Maven插件](https://gitee.com/smart-doc com.alibaba:fastjson - + @@ -159,7 +159,7 @@ smart-doc官方目前已经开发完成[Maven插件](https://gitee.com/smart-doc "codeField": "code",//错误码的code码字段名称 "descField": "message"//错误码的描述信息对应的字段名 }], - "revisionLogs": [{ //文档变更记录 + "revisionLogs": [{ //文档变更记录,非必须 "version": "1.0", //文档版本号 "revisionTime": "2020-12-31 10:30", //文档修订时间 "status": "update", //变更操作状态,一般为:创建、更新等 @@ -173,7 +173,7 @@ smart-doc官方目前已经开发完成[Maven插件](https://gitee.com/smart-doc "ownerClassName": "org.springframework.data.domain.Pageable", //指定你要添加注释的类名 "value": "00000"//设置响应码的值 }], - "customRequestFields": [{ //自定义请求体的注释,@since 2.1.3 + "customRequestFields": [{ //自定义请求体的注释,@since 2.1.3,非必须 "name":"code", //属性名 "desc":"状态码", //描述 "ownerClassName":"com.xxx.constant.entity.Result", //属性对应的类全路径 @@ -199,23 +199,20 @@ smart-doc官方目前已经开发完成[Maven插件](https://gitee.com/smart-doc "className": "org.springframework.data.domain.Pageable", "replacementClassName": "com.power.doc.model.PageRequestDto" //自定义的PageRequestDto替换Pageable做文档渲染 }], - "apiConstants": [{//从1.8.9开始配置自己的常量类,smart-doc在解析到常量时自动替换为具体的值 + "apiConstants": [{//从1.8.9开始配置自己的常量类,smart-doc在解析到常量时自动替换为具体的值,非必须 "constantsClassName": "com.power.doc.constants.RequestParamConstant" }], "responseBodyAdvice":{ //自smart-doc 1.9.8起,ResponseBodyAdvice统一返回设置,可用ignoreResponseBodyAdvice tag来忽略 "className":"com.power.common.model.CommonResult" //通用响应体 }, - "requestBodyAdvice":{ ////自smart-doc 2.1.4 起,支持设置RequestBodyAdvice统一请求包装类 + "requestBodyAdvice":{ ////自smart-doc 2.1.4 起,支持设置RequestBodyAdvice统一请求包装类,非必须 "className":"com.power.common.model.CommonResult" - }, - "sourceCodePaths": [{ //设置代码路径, 插件已经能够自动下载发布的源码包,没必要配置 - "path": "src/main/java", - "desc": "测试" - }] + } } ``` -上面的JSON配置实例中只有"outPath"是必填项。 +>上面的JSON配置实例中只有"outPath"是必填项。其他额外配置项请根据实际情况来配置,胡乱复制上面的全配置到自己的项目中 +可能引起使用错误 **注意:** 对于老用户完全可以通过`Fastjson`或者是`Gson`库将`ApiConfig`转化成JSON配置。 diff --git a/pom.xml b/pom.xml index 77c78d5a..91e7d7c2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 smart-doc jar - 2.1.8 + 2.1.9 smart-doc https://github.com/smart-doc-group/smart-doc.git diff --git a/src/main/java/com/power/doc/builder/TornaBuilder.java b/src/main/java/com/power/doc/builder/TornaBuilder.java index 5d4906b0..d4eeb282 100644 --- a/src/main/java/com/power/doc/builder/TornaBuilder.java +++ b/src/main/java/com/power/doc/builder/TornaBuilder.java @@ -85,7 +85,7 @@ public static void buildApiDoc(ApiConfig config, JavaProjectBuilder javaProjectB * * @param apiDocs apiData * @param apiConfig ApiConfig - * @param builder JavaProjectBuilder + * @param builder JavaProjectBuilder */ public static void buildTorna(List apiDocs, ApiConfig apiConfig, JavaProjectBuilder builder) { TornaApi tornaApi = new TornaApi(); @@ -109,7 +109,7 @@ public static void buildTorna(List apiDocs, ApiConfig apiConfig, JavaPro //推送字典信息 Map dicMap = new HashMap<>(2); List docDicts = TornaUtil.buildTornaDic(DocUtil.buildDictionary(apiConfig, builder)); - if(CollectionUtil.isNotEmpty(docDicts)) { + if (CollectionUtil.isNotEmpty(docDicts)) { dicMap.put("enums", docDicts); Map dicRequestJson = TornaConstants.buildParams(ENUM_PUSH, new Gson().toJson(dicMap), apiConfig); String dicResponseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(dicRequestJson)); diff --git a/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java b/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java index 6bf0b045..227eff7b 100644 --- a/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java +++ b/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java @@ -79,10 +79,10 @@ public static void buildApiDoc(ApiConfig config, JavaProjectBuilder javaProjectB ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder); RpcDocBuildTemplate docBuildTemplate = new RpcDocBuildTemplate(); List apiDocList = docBuildTemplate.getApiData(configBuilder); - buildTorna(apiDocList, config,javaProjectBuilder); + buildTorna(apiDocList, config, javaProjectBuilder); } - public static void buildTorna(List apiDocs, ApiConfig apiConfig,JavaProjectBuilder builder) { + public static void buildTorna(List apiDocs, ApiConfig apiConfig, JavaProjectBuilder builder) { TornaApi tornaApi = new TornaApi(); tornaApi.setAuthor(StringUtil.isEmpty(apiConfig.getAuthor()) ? System.getProperty("user.name") : apiConfig.getAuthor()); Apis api; @@ -110,10 +110,10 @@ public static void buildTorna(List apiDocs, ApiConfig apiConfig,JavaP Map requestJson = TornaConstants.buildParams(PUSH, new Gson().toJson(tornaApi), apiConfig); //推送字典信息 - Map dicMap = new HashMap<>(2); - List docDicts =TornaUtil.buildTornaDic(DocUtil.buildDictionary(apiConfig,builder)); + Map dicMap = new HashMap<>(2); + List docDicts = TornaUtil.buildTornaDic(DocUtil.buildDictionary(apiConfig, builder)); - if(CollectionUtil.isNotEmpty(docDicts)) { + if (CollectionUtil.isNotEmpty(docDicts)) { dicMap.put("enums", docDicts); Map dicRequestJson = TornaConstants.buildParams(ENUM_PUSH, new Gson().toJson(dicMap), apiConfig); String dicResponseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(dicRequestJson)); @@ -123,6 +123,6 @@ public static void buildTorna(List apiDocs, ApiConfig apiConfig,JavaP //获取返回结果 String responseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(requestJson)); //开启调试时打印请求信息 - TornaUtil.printDebugInfo(apiConfig, responseMsg, requestJson,PUSH); + TornaUtil.printDebugInfo(apiConfig, responseMsg, requestJson, PUSH); } }