fix out of index.

This commit is contained in:
oppofind 2020-12-26 02:20:22 +08:00
parent a2f9cce8f9
commit 94f1bf83fd
3 changed files with 16 additions and 9 deletions

View File

@ -9,6 +9,10 @@
4. 优化debug页面中的文件下载测试。
5. 优化enum入参mock错误的bug。
6. mock页面支持使用新窗口打开后端渲染的页面。
7. 修改生成一些字段值生成错误的bug。
8. 修改类中使用集合字段未指定泛型可能出错的bug。
9. 优化set等集合类在文档中的类型显示。
10. 添加对集合字段中枚举的处理。
#### 版本号2.0.1
- 更新日期: 2020-12-20
- 更新内容:

View File

@ -52,7 +52,7 @@ public class JsonBuildHelper {
public static String buildReturnJson(DocJavaMethod docJavaMethod, ProjectDocConfigBuilder builder) {
JavaMethod method = docJavaMethod.getJavaMethod();
if (method.getReturns().isVoid()) {
return "This api return nothing.";
return "void";
}
String returnTypeGenericCanonicalName = method.getReturnType().getGenericCanonicalName();
if (Objects.nonNull(builder.getApiConfig().getResponseBodyAdvice())
@ -74,6 +74,12 @@ public class JsonBuildHelper {
returnType = returnType.replace(entry.getKey(), entry.getValue().getCanonicalName());
}
}
if (JavaClassValidateUtil.isPrimitive(typeName)) {
if (DocGlobalConstants.JAVA_STRING_FULLY.equals(typeName)) {
return "string";
}
return StringUtil.removeQuotes(DocUtil.jsonValueByType(typeName));
}
return JsonFormatUtil.formatJson(buildJson(typeName, returnType, Boolean.TRUE, 0, new HashMap<>(), builder));
}
@ -109,9 +115,6 @@ public class JsonBuildHelper {
}
}
if (JavaClassValidateUtil.isPrimitive(typeName)) {
if (DocGlobalConstants.JAVA_STRING_FULLY.equals(typeName)) {
return "string";
}
return StringUtil.removeQuotes(DocUtil.jsonValueByType(typeName));
}
if (javaClass.isEnum()) {
@ -275,7 +278,7 @@ public class JsonBuildHelper {
String gicName = DocClassUtil.getSimpleGicName(fieldGicName)[0];
if (DocGlobalConstants.JAVA_STRING_FULLY.equals(gicName)) {
data0.append("[").append("\"").append(buildJson(gicName, fieldGicName, isResp, nextLevel, registryClasses, builder)).append("\"]").append(",");
data0.append("[").append(DocUtil.jsonValueByType(gicName)).append("]").append(",");
} else if (DocGlobalConstants.JAVA_LIST_FULLY.equals(gicName)) {
data0.append("[{\"object\":\"any object\"}],");
} else if (gicName.length() == 1) {
@ -285,7 +288,7 @@ public class JsonBuildHelper {
}
String gicName1 = genericMap.get(gicName) == null ? globGicName[0] : genericMap.get(gicName);
if (DocGlobalConstants.JAVA_STRING_FULLY.equals(gicName1)) {
data0.append("[").append("\"").append(buildJson(gicName1, gicName1, isResp, nextLevel, registryClasses, builder)).append("\"]").append(",");
data0.append("[").append(DocUtil.jsonValueByType(gicName1)).append("]").append(",");
} else {
if (!typeName.equals(gicName1)) {
data0.append("[").append(buildJson(DocClassUtil.getSimpleName(gicName1), gicName1, isResp, nextLevel, registryClasses, builder)).append("]").append(",");
@ -323,7 +326,7 @@ public class JsonBuildHelper {
if (gicName.length() == 1) {
String gicName1 = genericMap.get(gicName) == null ? globGicName[0] : genericMap.get(gicName);
if (DocGlobalConstants.JAVA_STRING_FULLY.equals(gicName1)) {
data0.append("{").append("\"mapKey\":\"").append(buildJson(gicName1, gicName1, isResp, nextLevel, registryClasses, builder)).append("\"},");
data0.append("{").append("\"mapKey\":").append(DocUtil.jsonValueByType(gicName1)).append("},");
} else {
if (!typeName.equals(gicName1)) {
data0.append("{").append("\"mapKey\":").append(buildJson(DocClassUtil.getSimpleName(gicName1), gicName1, isResp, nextLevel, registryClasses, builder)).append("},");

View File

@ -240,11 +240,12 @@ public class ParamsBuildHelper {
}
if (JavaClassValidateUtil.isCollection(subTypeName)) {
String gNameTemp = fieldGicName;
// like Student<T>, Student class has a field List<T> lists.
if (globGicName.length > 0 && JAVA_LIST_FULLY.equals(gNameTemp)) {
gNameTemp = gNameTemp + "<T>";
}
String[] gNameArr = DocClassUtil.getSimpleGicName(gNameTemp);
if (gNameArr.length >= 0) {
if (gNameArr.length > 0) {
String gName = DocClassUtil.getSimpleGicName(gNameTemp)[0];
JavaClass javaClass1 = projectBuilder.getJavaProjectBuilder().getClassByName(gName);
comment = comment + handleEnumComment(javaClass1, projectBuilder);
@ -294,7 +295,6 @@ public class ParamsBuildHelper {
param.setEnumValues(JavaClassUtil.getEnumValues(javaClass));
param.setType(DocGlobalConstants.ENUM);
}
if (StringUtil.isNotEmpty(comment)) {
commonHandleParam(paramList, param, isRequired, comment + appendComment, since, strRequired);
} else {