fix(接口测试): swagger3.0导入导出错误
--user=郭雨琦 --bug=1012087 【接口测试】 github#12447 ,swagger url导入接口文档,字段的 值 丢失 https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001012087
This commit is contained in:
parent
e847f0c602
commit
91f377fbf8
|
@ -511,6 +511,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
Map<String, JsonSchemaItem> JsonSchemaProperties = new LinkedHashMap<>();
|
Map<String, JsonSchemaItem> JsonSchemaProperties = new LinkedHashMap<>();
|
||||||
properties.forEach((key, value) -> {
|
properties.forEach((key, value) -> {
|
||||||
JsonSchemaItem item = new JsonSchemaItem();
|
JsonSchemaItem item = new JsonSchemaItem();
|
||||||
|
item.setType(schema.getType());
|
||||||
item.setDescription(schema.getDescription());
|
item.setDescription(schema.getDescription());
|
||||||
JsonSchemaItem proItem = parseSchema(value, refSet);
|
JsonSchemaItem proItem = parseSchema(value, refSet);
|
||||||
if (proItem != null) JsonSchemaProperties.put(key, proItem);
|
if (proItem != null) JsonSchemaProperties.put(key, proItem);
|
||||||
|
@ -739,11 +740,11 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
} else if (StringUtils.equals(type, "object")) {
|
} else if (StringUtils.equals(type, "object")) {
|
||||||
parsedParam.put("type", "object");
|
parsedParam.put("type", "object");
|
||||||
JSONObject properties = requestBody.getJSONObject("properties");
|
JSONObject properties = requestBody.getJSONObject("properties");
|
||||||
|
JSONObject jsonObject = buildFormDataSchema(properties);
|
||||||
if (StringUtils.isNotBlank(requestBody.getString("description"))) {
|
if (StringUtils.isNotBlank(requestBody.getString("description"))) {
|
||||||
parsedParam.put("description", requestBody.getString("description"));
|
parsedParam.put("description", requestBody.getString("description"));
|
||||||
}
|
}
|
||||||
parsedParam.put("properties", properties);
|
parsedParam.put("properties", jsonObject.getJSONObject("properties"));
|
||||||
} else if (StringUtils.equals(type, "integer")) {
|
} else if (StringUtils.equals(type, "integer")) {
|
||||||
parsedParam.put("type", "integer");
|
parsedParam.put("type", "integer");
|
||||||
parsedParam.put("format", "int64");
|
parsedParam.put("format", "int64");
|
||||||
|
@ -828,7 +829,13 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
JSONObject obj = ((JSONObject) kvs.get(key));
|
JSONObject obj = ((JSONObject) kvs.get(key));
|
||||||
property.put("type", StringUtils.isNotEmpty(obj.getString("type")) ? obj.getString("type") : "string");
|
property.put("type", StringUtils.isNotEmpty(obj.getString("type")) ? obj.getString("type") : "string");
|
||||||
String value = obj.getString("value");
|
String value = obj.getString("value");
|
||||||
|
if(StringUtils.isBlank(value)){
|
||||||
|
JSONObject mock = obj.getJSONObject("mock");
|
||||||
|
Object mockValue = mock.get("mock");
|
||||||
|
property.put("example", mockValue);
|
||||||
|
}else{
|
||||||
property.put("example", value);
|
property.put("example", value);
|
||||||
|
}
|
||||||
property.put("description", obj.getString("description"));
|
property.put("description", obj.getString("description"));
|
||||||
property.put("required", obj.getString("required"));
|
property.put("required", obj.getString("required"));
|
||||||
properties.put(key, property);
|
properties.put(key, property);
|
||||||
|
|
Loading…
Reference in New Issue