fix(接口测试): 接口定义导出swagger时增加长度信息导出

https://www.tapd.cn/55049933/s/1606733
This commit is contained in:
Jianguo-Genius 2024-11-06 15:37:43 +08:00 committed by Craftsman
parent da1beb3fa1
commit 645a00b3cf
1 changed files with 16 additions and 1 deletions

View File

@ -131,7 +131,14 @@ public class Swagger3ExportParser implements ExportParser<ApiDefinitionExportRes
JSONObject schema = new JSONObject();
schema.put(PropertyConstant.TYPE, PropertyConstant.STRING);
swaggerParam.setSchema(JSONUtil.parseObjectNode(schema.toString()));
paramsList.add(JSONUtil.parseObject(JSON.toJSONString(swaggerParam)));
JSONObject schemaObject = JSONUtil.parseObject(JSON.toJSONString(swaggerParam));
if (StringUtils.isNotBlank(param.optString("maxLength"))) {
schemaObject.put("maxLength", param.optInt("maxLength"));
}
if (StringUtils.isNotBlank(param.optString("minLength"))) {
schemaObject.put("minLength", param.optInt("minLength"));
}
paramsList.add(schemaObject);
}
}
}
@ -345,6 +352,7 @@ public class Swagger3ExportParser implements ExportParser<ApiDefinitionExportRes
}
private JSONObject getFormDataProperties(JSONArray requestBody) {
// todo maxLength minLength
JSONObject result = new JSONObject();
for (Object item : requestBody) {
if (item instanceof JSONObject) {
@ -575,6 +583,13 @@ public class Swagger3ExportParser implements ExportParser<ApiDefinitionExportRes
}
}
}
if (StringUtils.isNotBlank(obj.optString("maxLength"))) {
property.put("maxLength", obj.optInt("maxLength"));
}
if (StringUtils.isNotBlank(obj.optString("minLength"))) {
property.put("minLength", obj.optInt("minLength"));
}
properties.put(key, property);
}
schema.put(PropertyConstant.PROPERTIES, properties);