fix output doc error while entity extend Model

This commit is contained in:
oppofind 2019-11-19 23:07:21 +08:00
parent 3addd29729
commit d5e770a78f
5 changed files with 53 additions and 7 deletions

View File

@ -121,12 +121,18 @@
3. 增加请求参数枚举字段解析(试用功能)
#### 版本号1.7.7
- 更新日期:待定
- 更新日期:2019-11-18
- 更新内容:
1. 修改timestamp类型字段创建json示例错误bug。
2. fix #I1545A 单接口多路径bug。
3. 修改部分url生成部署空格问题。
4. 优化对java.util.concurrent.ConcurrentMap的解析。
#### 版本号1.7.8
- 更新日期:待定
- 更新内容:
1. 修改Spring Controller使用非Spring Web注解时生成的响应示例出错的bug。
2. 修改使用mybatis-plus实体继承Model对象时将log字段输出到文档的问题。
3. 添加对transient修饰字段文档输出开关默认不输出。

View File

@ -274,7 +274,7 @@ public class SourceBuilder {
if (urls.length > 1) {
url = getUrls(baseUrl, urls);
} else {
url = UrlUtil.simplifyUrl(this.appUrl + "/" + baseUrl + "/" + url) ;
url = UrlUtil.simplifyUrl(this.appUrl + "/" + baseUrl + "/" + url);
}
apiMethodDoc.setType(methodType);
apiMethodDoc.setUrl(url);
@ -473,11 +473,13 @@ public class SourceBuilder {
out:
for (JavaField field : fields) {
String fieldName = field.getName();
if ("this$0".equals(fieldName) || "serialVersionUID".equals(fieldName)) {
String subTypeName = field.getType().getFullyQualifiedName();
if ("this$0".equals(fieldName) ||
"serialVersionUID".equals(fieldName) ||
DocClassUtil.isIgnoreFieldTypes(subTypeName)) {
continue;
}
String typeSimpleName = field.getType().getSimpleName();
String subTypeName = field.getType().getFullyQualifiedName();
String fieldGicName = field.getType().getGenericCanonicalName();
List<JavaAnnotation> javaAnnotations = field.getAnnotations();
@ -804,8 +806,11 @@ public class SourceBuilder {
int i = 0;
out:
for (JavaField field : fields) {
String subTypeName = field.getType().getFullyQualifiedName();
String fieldName = field.getName();
if ("this$0".equals(fieldName) || "serialVersionUID".equals(fieldName)) {
if ("this$0".equals(fieldName) ||
"serialVersionUID".equals(fieldName) ||
DocClassUtil.isIgnoreFieldTypes(subTypeName)) {
continue;
}
List<DocletTag> paramTags = field.getTags();
@ -837,7 +842,7 @@ public class SourceBuilder {
}
}
String typeSimpleName = field.getType().getSimpleName();
String subTypeName = field.getType().getFullyQualifiedName();
String fieldGicName = field.getType().getGenericCanonicalName();
data0.append("\"").append(fieldName).append("\":");
if (DocClassUtil.isPrimitive(subTypeName)) {
@ -1000,6 +1005,10 @@ public class SourceBuilder {
String defaultVal = null;
boolean notHasRequestParams = true;
for (JavaAnnotation annotation : annotations) {
String fullName = annotation.getType().getFullyQualifiedName();
if (!fullName.contains(DocGlobalConstants.SPRING_WEB_ANNOTATION_PACKAGE)) {
continue;
}
String annotationName = annotation.getType().getSimpleName();
if (REQUEST_BODY.equals(annotationName) || DocGlobalConstants.REQUEST_BODY_FULLY.equals(annotationName)) {
requestBodyCounter++;
@ -1270,7 +1279,7 @@ public class SourceBuilder {
|| DocAnnotationConstants.SHORT_REST_CONTROLLER.equals(annotationName)
|| DocGlobalConstants.REST_CONTROLLER_FULLY.equals(annotationName)
|| DocGlobalConstants.CONTROLLER_FULLY.equals(annotationName)
) {
) {
return true;
}
}

View File

@ -88,4 +88,6 @@ public class DocGlobalConstants {
public static final String ANY_OBJECT_MSG = "any object.";
public static final String NO_COMMENTS_FOUND = "No comments found.";
public static final String SPRING_WEB_ANNOTATION_PACKAGE = "org.springframework.web.bind.annotation";
}

View File

@ -103,6 +103,11 @@ public class ApiConfig {
*/
private String projectName;
/**
* Skip Transient Field
*/
private boolean skipTransientField = true;
public String getServerUrl() {
return serverUrl;
@ -235,4 +240,12 @@ public class ApiConfig {
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public boolean isSkipTransientField() {
return skipTransientField;
}
public void setSkipTransientField(boolean skipTransientField) {
this.skipTransientField = skipTransientField;
}
}

View File

@ -404,6 +404,22 @@ public class DocClassUtil {
}
}
/**
* ignore field type name
* @param typeName field type name
* @return String
*/
public static boolean isIgnoreFieldTypes(String typeName){
switch (typeName) {
case "org.slf4j.Logger":
return true;
case "org.apache.ibatis.logging.Log":
return true;
default:
return false;
}
}
/**
* process return type
*