Skip to content

Commit

Permalink
- 修复返回参数 String 集合问题
Browse files Browse the repository at this point in the history
- 新增 YApi 上传成功后通知信息为可点击链接
  • Loading branch information
liuzhihang committed Jul 21, 2021
1 parent e99c1cd commit 1f41a3c
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions src/main/java/com/liuzhihang/doc/view/utils/ParamPsiUtils.java
Original file line number Diff line number Diff line change
@@ -329,7 +329,6 @@ public static void buildBodyList(@NotNull PsiClass psiClass, PsiType[] o, Body p
@NotNull
public static String getRespBodyJson(PsiType returnType) {


if (returnType instanceof PsiPrimitiveType || FieldTypeConstant.FIELD_TYPE.containsKey(returnType.getPresentableText())) {
return "";
} else if (returnType instanceof PsiClassType) {
@@ -338,22 +337,30 @@ public static String getRespBodyJson(PsiType returnType) {

PsiClass psiClass = PsiUtil.resolveClassInType(returnType);
if (psiClass != null) {

// 返回类型是集合
if (InheritanceUtil.isInheritor(psiClass, CommonClassNames.JAVA_UTIL_COLLECTION)) {
// 集合类型
PsiType[] parameters = psiClassType.getParameters();

if (parameters.length == 0) {
// 获取泛型
PsiType iterableType = PsiUtil.extractIterableTypeParameter(psiClassType, false);

if (iterableType == null) {
return "[]";
}

PsiType psiType = parameters[0];

if (psiType instanceof PsiPrimitiveType || FieldTypeConstant.FIELD_TYPE.containsKey(psiType.getPresentableText())) {
if (iterableType instanceof PsiPrimitiveType) {
return "[]";
}

PsiClass iterableClass = PsiUtil.resolveClassInClassTypeOnly(psiType);
if (CommonClassNames.JAVA_LANG_STRING_SHORT.equals(iterableType.getPresentableText())) {
return "[\"\"]";
}

if (FieldTypeConstant.FIELD_TYPE.containsKey(iterableType.getPresentableText())) {
return "[\"\"]";
}

PsiClass iterableClass = PsiUtil.resolveClassInClassTypeOnly(iterableType);
Map<String, Object> fieldMap = ParamPsiUtils.getFieldsAndDefaultValue(iterableClass, null);

Object[] objectArr = {fieldMap};
2 changes: 1 addition & 1 deletion src/main/resources/messages/DocViewBundle.properties
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ notify.spring.error.method=\u5F53\u524D\u65B9\u6CD5\u4E0D\u6EE1\u8DB3\u6761\u4EF
notify.spring.error.no.method=\u5F53\u524D Controller \u4E2D\u6CA1\u6709\u6EE1\u8DB3\u6761\u4EF6\u7684\u65B9\u6CD5!
notify.yapi.info.settings=\u8BF7\u6DFB\u52A0 YApi \u76F8\u5173\u914D\u7F6E
notify.yapi.upload.error=\u63A5\u53E3\u4E0A\u4F20 YApi \u5931\u8D25
notify.yapi.upload.success=\u63A5\u53E3\u4E0A\u4F20 YApi \u6210\u529F, \u63A5\u53E3\u5730\u5740\u4E3A: {0}
notify.yapi.upload.success=\u63A5\u53E3\u4E0A\u4F20 YApi \u6210\u529F, \u63A5\u53E3\u5730\u5740\u4E3A: <p><a href={0}>{0}</a>
notify.not.support.jcef=\u5F53\u524D IDEA \u7248\u672C\u4E0D\u652F\u6301 JCEF, \u65E0\u6CD5\u9884\u89C8.
notify.yapi.project.id=\u9879\u76EE id (projectId) \u8BF7\u8F93\u5165\u6570\u5B57
#

0 comments on commit 1f41a3c

Please sign in to comment.