提交 656eef29 authored 作者: 黄承天's avatar 黄承天

[函数回调]修正字段描述信息

上级 f6a34c06
package com.tykj.workflowcore.api.controller;
import com.tykj.workflowcore.api.annotations.Callable;
import com.tykj.workflowcore.api.annotations.CallableApi;
import com.tykj.workflowcore.api.entity.ApiInfo;
import com.tykj.workflowcore.api.entity.ClassInfo;
import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.service.ApiService;
import io.swagger.annotations.Api;
......
......@@ -66,10 +66,10 @@ public class ApiService {
//确认CallableApi注解
if (method.isAnnotationPresent(CallableApi.class)) {
List<EntityInfo> params = Arrays.stream(method.getParameters())
.map(parameter -> entityInfo(parameter.getType(), parameter.getName()))
.map(parameter -> entityInfo(parameter.getType(), parameter.getName(), Strings.EMPTY))
.collect(Collectors.toList());
Class<?> returnType = method.getReturnType();
EntityInfo ret = entityInfo(returnType, Strings.EMPTY);
EntityInfo ret = entityInfo(returnType, Strings.EMPTY, Strings.EMPTY);
ApiOperation methodAnnotation = method.getAnnotation(ApiOperation.class);
String description = Strings.EMPTY;
if (nonNull(methodAnnotation)) {
......@@ -81,10 +81,9 @@ public class ApiService {
}
}
private EntityInfo entityInfo(Class<?> clz, String name) {
private EntityInfo entityInfo(Class<?> clz, String name, String description) {
String classType = clz.getCanonicalName();
List<EntityInfo> fields = new ArrayList<>();
String description = Strings.EMPTY;
if (isNotBasicClass(clz)) {
for (Field field : clz.getDeclaredFields()) {
Class<?> fieldClass = field.getType();
......@@ -92,14 +91,15 @@ public class ApiService {
field.setAccessible(true);
//读取swagger描述信息
ApiModelProperty fieldAnnotation = field.getAnnotation(ApiModelProperty.class);
String fieldDescription = Strings.EMPTY;
if (nonNull(fieldAnnotation)) {
description = fieldAnnotation.value();
fieldDescription = fieldAnnotation.value();
}
//确认类中是否嵌套了相同类型的字段 防止死循环
boolean isDifferentClass = !Objects.equals(clz, fieldClass);
EntityInfo fieldClassInfo;
if (isDifferentClass) {
fieldClassInfo = entityInfo(fieldClass, fieldName);
fieldClassInfo = entityInfo(fieldClass, fieldName, fieldDescription);
} else {
fieldClassInfo = new EntityInfo(fieldClass.getSimpleName(), field.getName(),"", new ArrayList<>(), description);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论