diff --git a/README.md b/README.md index 478ca264..7d7c2e73 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ Thanks to the following people who have submitted major pull requests: - [@qinkangdeid](https://github.com/qinkangdeid) - [@br7roy](https://github.com/br7roy) - [@caiqyxyx](https://gitee.com/cy-work) +- [@lichoking](https://gitee.com/lichoking) ## Other reference - [Smart-doc manual](https://github.com/shalousun/smart-doc/wiki) diff --git a/README_CN.md b/README_CN.md index 2adaedcb..29e3a968 100644 --- a/README_CN.md +++ b/README_CN.md @@ -170,6 +170,7 @@ mvn clean install -Dmaven.test.skip=true - [@qinkangdeid](https://github.com/qinkangdeid) - [@br7roy](https://github.com/br7roy) - [@caiqyxyx](https://gitee.com/cy-work) +- [@lichoking](https://gitee.com/lichoking) ## Other reference - [smart-doc功能使用介绍](https://my.oschina.net/u/1760791/blog/2250962) - [smart-doc官方wiki](https://gitee.com/sunyurepository/smart-doc/wikis/Home?sort_id=1652800) diff --git a/pom.xml b/pom.xml index e7cf0da4..99f4d913 100644 --- a/pom.xml +++ b/pom.xml @@ -5,11 +5,11 @@ 4.0.0 smart-doc jar - 1.8.4 + 1.8.5 smart-doc https://github.com/shalousun/smart-doc.git - smart-doc + smart-doc is a java restful api document generation tool. @@ -38,7 +38,7 @@ junit junit - 4.12 + 4.13 test @@ -59,7 +59,7 @@ com.github.shalousun common-util - 1.9.2 + 1.9.3 diff --git a/src/main/java/com/power/doc/filter/WebFluxReturnFilter.java b/src/main/java/com/power/doc/filter/WebFluxReturnFilter.java index 208d2db4..8a9bb1ad 100644 --- a/src/main/java/com/power/doc/filter/WebFluxReturnFilter.java +++ b/src/main/java/com/power/doc/filter/WebFluxReturnFilter.java @@ -30,13 +30,15 @@ */ public class WebFluxReturnFilter implements ReturnTypeFilter { + private static final String FLUX = "reactor.core.publisher.Flux"; + @Override public ApiReturn doFilter(String fullyName) { //support web flux - if (fullyName.startsWith("reactor.core.publisher.Flux")) { + if (fullyName.startsWith(FLUX)) { ApiReturn apiReturn = new ApiReturn(); // rewrite type name - fullyName = fullyName.replace("reactor.core.publisher.Flux", DocGlobalConstants.JAVA_LIST_FULLY); + fullyName = fullyName.replace(FLUX, DocGlobalConstants.JAVA_LIST_FULLY); apiReturn.setGenericCanonicalName(fullyName); apiReturn.setSimpleName(DocGlobalConstants.JAVA_LIST_FULLY); return apiReturn; diff --git a/src/main/java/com/power/doc/utils/DocUtil.java b/src/main/java/com/power/doc/utils/DocUtil.java index f777daee..9b3f9265 100644 --- a/src/main/java/com/power/doc/utils/DocUtil.java +++ b/src/main/java/com/power/doc/utils/DocUtil.java @@ -34,8 +34,6 @@ import org.apache.commons.codec.digest.DigestUtils; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -52,8 +50,6 @@ public class DocUtil { private static String CLASS_PATTERN = "^([A-Za-z]{1}[A-Za-z\\d_]*\\.)+[A-Za-z][A-Za-z\\d_]*$"; - public static final String CONTAINS_CHINESE_PATTERN = "[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]"; - private static Map fieldValue = new LinkedHashMap<>(); static { @@ -144,7 +140,6 @@ public static String jsonValueByType(String typeName) { */ public static String getValByTypeAndFieldName(String typeName, String filedName) { boolean isArray = true; - String type = typeName.contains("java.lang") ? typeName.substring(typeName.lastIndexOf(".") + 1, typeName.length()) : typeName; String key = filedName.toLowerCase() + "-" + type.toLowerCase(); StringBuilder value = null; @@ -201,7 +196,7 @@ public static boolean isClassName(String className) { if (StringUtil.isEmpty(className) || !className.contains(".")) { return false; } - if (isContainsChinese(className)) { + if (ValidateUtil.isContainsChinese(className)) { return false; } String classNameTemp = className; @@ -438,7 +433,7 @@ public static Map formDataToMap(List formDataList) { return formDataMap; } - private static boolean javaPrimaryType(String type) { + public static boolean javaPrimaryType(String type) { switch (type) { case "Integer": case "int": @@ -459,22 +454,4 @@ private static boolean javaPrimaryType(String type) { return false; } } - - /** - * contains chinese - * - * @param str str - * @return boolean - */ - public static boolean isContainsChinese(String str) { - if (StringUtil.isEmpty(str)) { - return true; - } - Pattern p = Pattern.compile(CONTAINS_CHINESE_PATTERN); - Matcher m = p.matcher(str); - if (m.find()) { - return true; - } - return false; - } }