Commit 48304bfa by 轻舟 Committed by inrgihc

!51 修复一些问题:

* 修复一些问题:
parent 6d764c30
......@@ -11,9 +11,12 @@ package com.gitee.sqlrest.common.enums;
import java.util.Map;
import java.util.function.Function;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import cn.hutool.json.JSONUtil;
import lombok.Getter;
@Getter
public enum ParamTypeEnum {
LONG("整型", "number", 0L, Long.class, (String str) -> StringUtils.isNotBlank(str) ? Long.valueOf(str) : null),
......@@ -21,8 +24,10 @@ public enum ParamTypeEnum {
STRING("字符串", "string", "", String.class, (String str) -> str),
DATE("日期", "string", "", String.class, (String str) -> str),
TIME("时间", "string", "", String.class, (String str) -> str),
BOOLEAN("布尔", "string", "true", Boolean.class, (String str) -> Boolean.parseBoolean(str)),
OBJECT("对象", "object", "{}", Map.class, s -> s);
//fix: 直接在swagger上展示boolean类型
BOOLEAN("布尔", "boolean", "true", Boolean.class, (String str) -> StringUtils.isNotBlank(str) ? Boolean.parseBoolean(str): null),
//fix: 修复对象不传时,默认值为空字符串问题
OBJECT("对象", "object", "{}", Map.class, (String str) -> StringUtils.isNotBlank(str) ? JSONUtil.toBean(str, Map.class) : null);
private String name;
private String jsType;
......
......@@ -87,8 +87,10 @@ public class ApiExecuteService {
}
return execute(config, paramValues);
} catch (CommonException e) {
log.warn("<SR出错>参数校验错误,错误消息:" + e.getMessage(), e);
return ResultEntity.failed(e.getCode(), e.getMessage());
} catch (Throwable t) {
log.warn("<SR出错>方法执行出错,错误消息:" + t.getMessage(), t);
return ResultEntity.failed(ResponseErrorCode.ERROR_INTERNAL_ERROR, ExceptionUtil.getMessage(t));
}
}
......
......@@ -78,6 +78,7 @@ public class AuthenticationFilter implements Filter {
String message = String.format("/%s/%s[%s]", Constants.API_PATH_PREFIX, path, method.name());
ResultEntity result = ResultEntity.failed(ResponseErrorCode.ERROR_PATH_NOT_EXISTS, message);
response.getWriter().append(JSONUtil.toJsonStr(result));
log.warn("<SR出错>404路径不存在:{}", message);
return;
}
......
......@@ -45,6 +45,7 @@ public class ApiServletService {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
String message = String.format("/%s/%s[%s]", Constants.API_PATH_PREFIX, path, method.name());
result = ResultEntity.failed(ResponseErrorCode.ERROR_PATH_NOT_EXISTS, message);
log.warn("<SR出错>404路径不存在:{}", message);
} else {
result = apiExecuteService.execute(apiConfigEntity, request);
}
......
......@@ -134,6 +134,9 @@ public class ApiSwaggerService {
Operation operation = new Operation();
operation.setOperationId(String.valueOf(assignment.getId()));
operation.addTagsItem(moduleIdMap.get(assignment.getModuleId()).getName());
//FIX:导入接口文档到apifox时,方法名不能正常显示接口名称问题
operation.setSummary(assignment.getName());
operation.setDescription(StringUtils.defaultIfBlank(assignment.getDescription(), assignment.getName()));
// 入参
List<ItemParam> params = assignment.getParams();
......@@ -285,6 +288,9 @@ public class ApiSwaggerService {
operation.setOperationId("0");
operation.addTagsItem(TOKEN_MODEL);
operation.setRequestBody(requestBody);
//FIX:导入接口文档到apifox时,方法名不能正常显示接口名称问题
operation.setSummary(TOKEN_MODEL);
operation.setDescription(TOKEN_MODEL);
ApiResponses apiResponses = new ApiResponses();
apiResponses.addApiResponse("200",
......
......@@ -723,6 +723,7 @@ export default {
{ name: "字符串", value: "STRING" },
{ name: "日期", value: "DATE" },
{ name: "时间", value: "TIME" },
{ name: "布尔", value: "BOOLEAN" },
{ name: "对象", value: "OBJECT" }
],
contentTypes: ['application/x-www-form-urlencoded', 'application/json'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment