diff --git a/src/main/java/com/power/doc/builder/ApiDocBuilder.java b/src/main/java/com/power/doc/builder/ApiDocBuilder.java index b6c574b..3679b29 100644 --- a/src/main/java/com/power/doc/builder/ApiDocBuilder.java +++ b/src/main/java/com/power/doc/builder/ApiDocBuilder.java @@ -58,6 +58,7 @@ public class ApiDocBuilder { public static List listOfApiData(ApiConfig config) { DocBuilderTemplate builderTemplate = new DocBuilderTemplate(); builderTemplate.checkAndInitForGetApiData(config); + config.setMd5EncryptedHtmlName(true); SourceBuilder sourceBuilder = new SourceBuilder(config); return sourceBuilder.getControllerApiData(); } @@ -72,6 +73,7 @@ public class ApiDocBuilder { public static ApiDoc getApiData(ApiConfig config, String controllerName) { DocBuilderTemplate builderTemplate = new DocBuilderTemplate(); builderTemplate.checkAndInitForGetApiData(config); + config.setMd5EncryptedHtmlName(true); SourceBuilder sourceBuilder = new SourceBuilder(config); return sourceBuilder.getSingleControllerApiData(controllerName); } diff --git a/src/main/java/com/power/doc/builder/SourceBuilder.java b/src/main/java/com/power/doc/builder/SourceBuilder.java index 7a4c8db..981df3e 100644 --- a/src/main/java/com/power/doc/builder/SourceBuilder.java +++ b/src/main/java/com/power/doc/builder/SourceBuilder.java @@ -149,6 +149,7 @@ public class SourceBuilder { } private List buildControllerMethod(final JavaClass cls) { + String clazName = cls.getCanonicalName(); List classAnnotations = cls.getAnnotations(); String baseUrl = ""; for (JavaAnnotation annotation : classAnnotations) { @@ -173,6 +174,9 @@ public class SourceBuilder { ApiMethodDoc apiMethodDoc = new ApiMethodDoc(); apiMethodDoc.setOrder(methodOrder); apiMethodDoc.setDesc(method.getComment()); + apiMethodDoc.setName(method.getName()); + String methodUid = clazName + method.getName(); + this.handleMethodUid(apiMethodDoc, methodUid); String apiNoteValue = DocUtil.getNormalTagComments(method, DocTags.API_NOTE, cls.getName()); if (StringUtil.isEmpty(apiNoteValue)) { apiNoteValue = method.getComment(); @@ -978,7 +982,7 @@ public class SourceBuilder { return builder.toString(); } if (requestBodyCounter < 1 && paraName != null) { - if(annotations.size()<1&& !DocClassUtil.isPrimitive(typeName)){ + if (annotations.size() < 1 && !DocClassUtil.isPrimitive(typeName)) { return "Smart-doc can't support create form-data example,It is recommended to use @RequestBody to receive parameters."; } if (StringUtil.isEmpty(defaultVal)) { @@ -1211,6 +1215,16 @@ public class SourceBuilder { } } + private void handleMethodUid(ApiMethodDoc methodDoc, String methodName) { + String name = DigestUtils.md5Hex(methodName); + int length = name.length(); + if (name.length() < 32) { + methodDoc.setMethodId(name); + } else { + methodDoc.setMethodId(name.substring(length - 32, length)); + } + } + private void commonHandleParam(List paramList, ApiParam param, String isRequired, String comment, String since, boolean strRequired) { if (StringUtil.isEmpty(isRequired)) { param.setDesc(comment).setVersion(since); diff --git a/src/main/java/com/power/doc/model/ApiMethodDoc.java b/src/main/java/com/power/doc/model/ApiMethodDoc.java index db33ef2..a28867c 100644 --- a/src/main/java/com/power/doc/model/ApiMethodDoc.java +++ b/src/main/java/com/power/doc/model/ApiMethodDoc.java @@ -10,6 +10,20 @@ public class ApiMethodDoc implements Serializable { private static final long serialVersionUID = 7211922919532562867L; + + /** + * methodId handled by md5 + * @since 1.7.3 + + * + */ + private String methodId; + + /** + * method name + * @since 1.7.3 + + */ + private String name; + /** * method order * @@ -17,6 +31,7 @@ public class ApiMethodDoc implements Serializable { */ private int order; + /** * method description */ @@ -75,6 +90,22 @@ public class ApiMethodDoc implements Serializable { private List responseParams; + public String getMethodId() { + return methodId; + } + + public void setMethodId(String methodId) { + this.methodId = methodId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getDesc() { return desc; }