diff --git a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java index 65c3b77..75b93f1 100644 --- a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java +++ b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java @@ -116,12 +116,6 @@ public class DocBuilderTemplate { } } - /** - * Merge all api doc into one document - * - * @param apiDocList list data of Api doc - */ - /** * Merge all api doc into one document * diff --git a/src/main/java/com/power/doc/builder/ProjectDocConfigBuilder.java b/src/main/java/com/power/doc/builder/ProjectDocConfigBuilder.java index 16f4f60..aa05886 100644 --- a/src/main/java/com/power/doc/builder/ProjectDocConfigBuilder.java +++ b/src/main/java/com/power/doc/builder/ProjectDocConfigBuilder.java @@ -84,9 +84,6 @@ public class ProjectDocConfigBuilder { if (CollectionUtil.isEmpty(paths)) { builder.addSourceTree(new File(DocGlobalConstants.PROJECT_CODE_PATH)); } else { - if (!paths.contains(DocGlobalConstants.PROJECT_CODE_PATH)) { - builder.addSourceTree(new File(DocGlobalConstants.PROJECT_CODE_PATH)); - } for (SourceCodePath path : paths) { if (null == path) { continue; diff --git a/src/main/java/com/power/doc/constants/DocAnnotationConstants.java b/src/main/java/com/power/doc/constants/DocAnnotationConstants.java index 7f92070..af8d020 100644 --- a/src/main/java/com/power/doc/constants/DocAnnotationConstants.java +++ b/src/main/java/com/power/doc/constants/DocAnnotationConstants.java @@ -5,31 +5,31 @@ package com.power.doc.constants; * * @author yu 2019/9/19. */ -public class DocAnnotationConstants { +public interface DocAnnotationConstants { - public static final String SHORT_CONTROLLER = "Controller"; + String SHORT_CONTROLLER = "Controller"; - public static final String SHORT_REST_CONTROLLER = "RestController"; + String SHORT_REST_CONTROLLER = "RestController"; - public static final String SHORT_PATH_VARIABLE = "PathVariable"; + String SHORT_PATH_VARIABLE = "PathVariable"; - public static final String SHORT_REQ_PARAM = "RequestParam"; + String SHORT_REQ_PARAM = "RequestParam"; - public static final String SHORT_JSON_IGNORE = "JsonIgnore"; + String SHORT_JSON_IGNORE = "JsonIgnore"; - public static final String SHORT_JSON_PROPERTY = "JsonProperty"; + String SHORT_JSON_PROPERTY = "JsonProperty"; - public static final String SHORT_JSON_FIELD = "JSONField"; + String SHORT_JSON_FIELD = "JSONField"; - public static final String REQUIRED_PROP = "required"; + String REQUIRED_PROP = "required"; - public static final String SERIALIZE_PROP = "serialize"; + String SERIALIZE_PROP = "serialize"; - public static final String NAME_PROP = "name"; + String NAME_PROP = "name"; - public static final String VALUE_PROP = "value"; + String VALUE_PROP = "value"; - public static final String DEFAULT_VALUE_PROP = "defaultValue"; + String DEFAULT_VALUE_PROP = "defaultValue"; - public static final String REQUEST_MAPPING = "RequestMapping"; + String REQUEST_MAPPING = "RequestMapping"; } diff --git a/src/main/java/com/power/doc/constants/DocTags.java b/src/main/java/com/power/doc/constants/DocTags.java index 210592c..479ba46 100644 --- a/src/main/java/com/power/doc/constants/DocTags.java +++ b/src/main/java/com/power/doc/constants/DocTags.java @@ -3,40 +3,40 @@ package com.power.doc.constants; /** * @author yu 2019/9/13. */ -public class DocTags { +public interface DocTags { /** * java since tag */ - public static final String SINCE = "since"; + String SINCE = "since"; /** * java required tag */ - public static final String REQUIRED = "required"; + String REQUIRED = "required"; /** * java param tag */ - public static final String PARAM = "param"; + String PARAM = "param"; /** * java apiNote tag for method detail */ - public static final String API_NOTE = "apiNote"; + String API_NOTE = "apiNote"; /** * java author tag for method author */ - public static final String AUTHOR = "author"; + String AUTHOR = "author"; /** * custom ignore tag */ - public static final String IGNORE = "ignore"; + String IGNORE = "ignore"; /** * custom @mock tag */ - public static final String MOCK = "mock"; + String MOCK = "mock"; } diff --git a/src/main/java/com/power/doc/constants/SpringMvcAnnotations.java b/src/main/java/com/power/doc/constants/SpringMvcAnnotations.java index 33efb1f..3332f68 100644 --- a/src/main/java/com/power/doc/constants/SpringMvcAnnotations.java +++ b/src/main/java/com/power/doc/constants/SpringMvcAnnotations.java @@ -25,27 +25,27 @@ package com.power.doc.constants; /** * @author yu 2019/12/21. */ -public class SpringMvcAnnotations { +public interface SpringMvcAnnotations { - public static final String REQUEST_MAPPING = "RequestMapping"; + String REQUEST_MAPPING = "RequestMapping"; - public static final String GET_MAPPING = "GetMapping"; + String GET_MAPPING = "GetMapping"; - public static final String POST_MAPPING = "PostMapping"; + String POST_MAPPING = "PostMapping"; - public static final String PUT_MAPPING = "PutMapping"; + String PUT_MAPPING = "PutMapping"; - public static final String DELETE_MAPPING = "DeleteMapping"; + String DELETE_MAPPING = "DeleteMapping"; - public static final String REQUEST_HERDER = "RequestHeader"; + String REQUEST_HERDER = "RequestHeader"; - public static final String REQUEST_PARAM = "RequestParam"; + String REQUEST_PARAM = "RequestParam"; - public static final String REQUEST_BODY = "RequestBody"; + String REQUEST_BODY = "RequestBody"; - public static final String CONTROLLER = "Controller"; + String CONTROLLER = "Controller"; - public static final String REST_CONTROLLER = "RestController"; + String REST_CONTROLLER = "RestController"; - public static final String PATH_VARIABLE = "PathVariable"; + String PATH_VARIABLE = "PathVariable"; } diff --git a/src/main/java/com/power/doc/constants/ValidatorAnnotations.java b/src/main/java/com/power/doc/constants/ValidatorAnnotations.java index a6374f0..e314907 100644 --- a/src/main/java/com/power/doc/constants/ValidatorAnnotations.java +++ b/src/main/java/com/power/doc/constants/ValidatorAnnotations.java @@ -25,7 +25,7 @@ package com.power.doc.constants; /** * @author yu 2019/12/22. */ -public class ValidatorAnnotations { +public interface ValidatorAnnotations { - public static final String VALID = "Valid"; + String VALID = "Valid"; } diff --git a/src/main/java/com/power/doc/helper/JsonBuildHelper.java b/src/main/java/com/power/doc/helper/JsonBuildHelper.java index d2c4ae4..89c5b90 100644 --- a/src/main/java/com/power/doc/helper/JsonBuildHelper.java +++ b/src/main/java/com/power/doc/helper/JsonBuildHelper.java @@ -147,10 +147,8 @@ public class JsonBuildHelper { } return data.toString(); } else if (DocGlobalConstants.JAVA_OBJECT_FULLY.equals(typeName)) { - if (DocGlobalConstants.JAVA_OBJECT_FULLY.equals(typeName)) { data.append("{\"object\":\" any object\"},"); // throw new RuntimeException("Please do not return java.lang.Object directly in api interface."); - } } else { List fields = JavaClassUtil.getFields(cls, 0); boolean isGenerics = JavaFieldUtil.checkGenerics(fields); @@ -311,7 +309,9 @@ public class JsonBuildHelper { } else { data0.append("{\"waring\":\"You may have used non-display generics.\"},"); } - if (!isGenerics) i++; + if (!isGenerics) { + i++; + } } else if (typeName.equals(subTypeName)) { data0.append("{\"$ref\":\"...\"}").append(","); } else { diff --git a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java index 5f1a5fe..4a8a88d 100644 --- a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java @@ -91,9 +91,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { @Override public boolean ignoreReturnObject(String typeName) { if (JavaClassValidateUtil.isMvcIgnoreParams(typeName)) { - if (DocGlobalConstants.MODE_AND_VIEW_FULLY.equals(typeName)) { - return true; - } + return DocGlobalConstants.MODE_AND_VIEW_FULLY.equals(typeName); } return false; } @@ -513,7 +511,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { if (JavaClassValidateUtil.isPrimitive(fullTypeName)) { ApiParam bodyParam = ApiParam.of() .setField(paramName).setType(DocClassUtil.processTypeNameForParams(simpleName)) - .setDesc(comment).setRequired(Boolean.valueOf(required)); + .setDesc(comment).setRequired(Boolean.parseBoolean(required)); reqBodyParamsList.add(bodyParam); } else { if (JavaClassValidateUtil.isCollection(fullTypeName) || JavaClassValidateUtil.isArray(fullTypeName)) { @@ -525,7 +523,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { if (JavaClassValidateUtil.isPrimitive(gicName)) { ApiParam bodyParam = ApiParam.of() .setField(paramName).setType(DocClassUtil.processTypeNameForParams(simpleName)) - .setDesc(comment).setRequired(Boolean.valueOf(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); + .setDesc(comment).setRequired(Boolean.parseBoolean(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); reqBodyParamsList.add(bodyParam); } else { reqBodyParamsList.addAll(ParamsBuildHelper.buildParams(gicNameArr[0], DocGlobalConstants.ENMPTY, 0, "true", responseFieldMap, Boolean.FALSE, new HashMap<>(), builder)); @@ -534,7 +532,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { } else if (JavaClassValidateUtil.isMap(fullTypeName)) { if (DocGlobalConstants.JAVA_MAP_FULLY.equals(typeName)) { ApiParam apiParam = ApiParam.of().setField(paramName).setType("map") - .setDesc(comment).setRequired(Boolean.valueOf(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); + .setDesc(comment).setRequired(Boolean.parseBoolean(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); paramList.add(apiParam); continue out; } @@ -562,13 +560,13 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { } ApiParam param = ApiParam.of().setField(paramName) .setType(DocClassUtil.processTypeNameForParams(simpleName)) - .setDesc(comment).setRequired(Boolean.valueOf(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); + .setDesc(comment).setRequired(Boolean.parseBoolean(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); paramList.add(param); paramAdded = true; } else if (validatorAnnotations.contains(annotationName)) { ApiParam param = ApiParam.of().setField(paramName) .setType(DocClassUtil.processTypeNameForParams(simpleName)) - .setDesc(comment).setRequired(Boolean.valueOf(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); + .setDesc(comment).setRequired(Boolean.parseBoolean(required)).setVersion(DocGlobalConstants.DEFAULT_VERSION); paramList.add(param); paramAdded = true; } else {