diff --git a/CHANGELOG.md b/CHANGELOG.md index 50dd3b72..bf00c066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## smart-doc版本 版本小于1.0都属于试用,正式1.0起始发布将会等到文中提到的问题解决后才发布。 +#### 版本号:2.1.6 +- 更新日期: 2020-05-10 +- 更新内容: + 1. 修复不允许List中放文件上传对象错误的bug。 + 2. 添加推送接口作者信息到torna。 + 3. 添加推送queryParams参数到torna(需要使用torna 1.6.0+) #### 版本号:2.1.5 - 更新日期: 2020-05-05 - 更新内容: diff --git a/pom.xml b/pom.xml index 54ec7f39..a55a68fa 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 smart-doc jar - 2.1.5 + 2.1.6 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 b42a1a24..abbe0514 100644 --- a/src/main/java/com/power/doc/builder/TornaBuilder.java +++ b/src/main/java/com/power/doc/builder/TornaBuilder.java @@ -98,6 +98,7 @@ public static void buildTorna(List apiDocs, ApiConfig apiConfig) { api.setName(StringUtils.isBlank(a.getDesc()) ? a.getName() : a.getDesc()); api.setItems(buildApis(a.getList(), TornaUtil.setDebugEnv(apiConfig,tornaApi))); api.setIsFolder(TornaConstants.YES); + api.setAuthor(apiConfig.getAuthor()); apisList.add(api); } tornaApi.setApis(apisList); 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 05ee855d..6b4cf8bd 100644 --- a/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java +++ b/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java @@ -64,6 +64,7 @@ public static void buildTorna(List apiDocs, ApiConfig apiConfig) { TornaUtil.setDebugEnv(apiConfig,tornaApi); api.setItems(buildDubboApis(a.getList())); api.setIsFolder(TornaConstants.YES); + api.setAuthor(apiConfig.getAuthor()); api.setDubboInfo(new DubboInfo().builder() .setAuthor(a.getAuthor()) .setProtocol(a.getProtocol()) diff --git a/src/main/java/com/power/doc/model/ApiConfig.java b/src/main/java/com/power/doc/model/ApiConfig.java index 440d517d..0f3012d6 100644 --- a/src/main/java/com/power/doc/model/ApiConfig.java +++ b/src/main/java/com/power/doc/model/ApiConfig.java @@ -325,14 +325,14 @@ public class ApiConfig { /** * 是否为dubbo */ - private boolean isDubbo; + private String author; - public boolean isDubbo() { - return isDubbo; + public String getAuthor() { + return author; } - public void setDubbo(boolean dubbo) { - this.isDubbo = dubbo; + public void setAuthor(String author) { + this.author = author; } public boolean isTornaDebug() { diff --git a/src/main/java/com/power/doc/model/torna/Apis.java b/src/main/java/com/power/doc/model/torna/Apis.java index 6055440e..f29e60f7 100644 --- a/src/main/java/com/power/doc/model/torna/Apis.java +++ b/src/main/java/com/power/doc/model/torna/Apis.java @@ -36,14 +36,24 @@ public class Apis { private String isFolder; private String parentId; private String isShow; + private String author; private DubboInfo dubboInfo; private List headerParams; private List pathParams; + private List queryParams; private List requestParams; private List responseParams; private String errorCodeParams; private List items; + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + public String getName() { return name; } @@ -108,6 +118,13 @@ public void setIsShow(String isShow) { this.isShow = isShow; } + public List getQueryParams() { + return queryParams; + } + + public void setQueryParams(List queryParams) { + this.queryParams = queryParams; + } public List getRequestParams() { return requestParams; diff --git a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java index b92bd68e..e083e8b8 100644 --- a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java @@ -46,7 +46,8 @@ import static com.power.doc.constants.DocGlobalConstants.FILE_CONTENT_TYPE; import static com.power.doc.constants.DocGlobalConstants.JSON_CONTENT_TYPE; -import static com.power.doc.constants.DocTags.*; +import static com.power.doc.constants.DocTags.IGNORE; +import static com.power.doc.constants.DocTags.IGNORE_REQUEST_BODY_ADVICE; /** * @author yu 2019/12/21. @@ -371,7 +372,7 @@ private ApiRequestExample buildReqJson(DocJavaMethod javaMethod, ApiMethodDoc ap typeName = configBuilder.getApiConfig().getRequestBodyAdvice().getClassName(); gicTypeName = requestBodyAdvice + "<" + gicTypeName + ">"; - } + } if (JavaClassValidateUtil.isPrimitive(simpleTypeName)) { StringBuilder builder = new StringBuilder(); @@ -420,7 +421,7 @@ private ApiRequestExample buildReqJson(DocJavaMethod javaMethod, ApiMethodDoc ap gicName = gicName.substring(0, gicName.indexOf("[")); } if (!JavaClassValidateUtil.isPrimitive(gicName) - &&!configBuilder.getJavaProjectBuilder().getClassByName(gicName).isEnum()) { + && !configBuilder.getJavaProjectBuilder().getClassByName(gicName).isEnum()) { throw new RuntimeException("Spring MVC can't support binding Collection on method " + method.getName() + "Check it in " + method.getDeclaringClass().getCanonicalName()); } @@ -602,7 +603,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje .setId(paramList.size() + 1).setQueryParam(true) .setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION) .setDesc(comment); - if (typeName.contains("[]")) { + if (typeName.contains("[]") || typeName.endsWith(">")) { comment = comment + "(array of file)"; param.setDesc(comment); param.setHasItems(true); @@ -661,7 +662,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje if (Objects.nonNull(builder.getApiConfig().getRequestBodyAdvice()) && Objects.isNull(javaMethod.getTagByName(IGNORE_REQUEST_BODY_ADVICE))) { String requestBodyAdvice = builder.getApiConfig().getRequestBodyAdvice().getClassName(); - fullTypeName = typeName = requestBodyAdvice + "<" + typeName + ">"; + fullTypeName = typeName = requestBodyAdvice + "<" + typeName + ">"; } requestBodyCounter++; @@ -683,7 +684,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje gicName = gicName.substring(0, gicName.indexOf("[")); } JavaClass gicJavaClass = builder.getJavaProjectBuilder().getClassByName(gicName); - if(gicJavaClass.isEnum()){ + if (gicJavaClass.isEnum()) { Object value = JavaClassUtil.getEnumValue(gicJavaClass, Boolean.TRUE); ApiParam param = ApiParam.of().setField(paramName).setDesc(comment + ",[array of enum]") .setRequired(required) @@ -704,7 +705,7 @@ private ApiMethodReqParam requestParams(final DocJavaMethod docJavaMethod, Proje .setQueryParam(queryParam) .setId(paramList.size() + 1) .setType("array") - .setValue(DocUtil.getValByTypeAndFieldName(gicName,paramName)); + .setValue(DocUtil.getValByTypeAndFieldName(gicName, paramName)); paramList.add(param); if (requestBodyCounter > 0) { Map map = OpenApiSchemaUtil.arrayTypeSchema(gicName); diff --git a/src/main/java/com/power/doc/utils/JavaClassValidateUtil.java b/src/main/java/com/power/doc/utils/JavaClassValidateUtil.java index f45cc8a3..2957f304 100644 --- a/src/main/java/com/power/doc/utils/JavaClassValidateUtil.java +++ b/src/main/java/com/power/doc/utils/JavaClassValidateUtil.java @@ -270,6 +270,7 @@ public static boolean isFile(String typeName){ case "org.springframework.web.multipart.MultipartFile[]": case "org.springframework.web.multipart.commons.CommonsMultipartFile": case "org.springframework.web.multipart.commons.CommonsMultipartFile[]": + case "java.util.List": return true; default: return false; diff --git a/src/main/java/com/power/doc/utils/TornaUtil.java b/src/main/java/com/power/doc/utils/TornaUtil.java index fa06ba51..7989d1c3 100644 --- a/src/main/java/com/power/doc/utils/TornaUtil.java +++ b/src/main/java/com/power/doc/utils/TornaUtil.java @@ -97,6 +97,7 @@ public static List buildApis(List apiMethodDocs, boolean has methodApi.setContentType(apiMethodDoc.getContentType()); methodApi.setDescription(apiMethodDoc.getDetail()); methodApi.setIsShow(TornaConstants.YES); + methodApi.setAuthor(apiMethodDoc.getAuthor()); /** * { @@ -129,7 +130,7 @@ public static List buildApis(List apiMethodDocs, boolean has } //formData if (CollectionUtil.isNotEmpty(apiMethodDoc.getQueryParams())) { - methodApi.setRequestParams(buildParams(apiMethodDoc.getQueryParams())); + methodApi.setQueryParams(buildParams(apiMethodDoc.getQueryParams())); } //Json if (CollectionUtil.isNotEmpty(apiMethodDoc.getRequestParams())) { @@ -167,6 +168,7 @@ public static List buildDubboApis(List apiMethodDocs) { methodApi.setName(apiMethodDoc.getDesc()); methodApi.setDescription(apiMethodDoc.getDetail()); methodApi.setIsShow(TornaConstants.YES); + methodApi.setAuthor(apiMethodDoc.getAuthor()); methodApi.setUrl(apiMethodDoc.getMethodDefinition()); /**