refactor(接口测试): 优化formData类型导出

This commit is contained in:
WangXu10 2024-07-16 11:09:31 +08:00 committed by Craftsman
parent ed7d40175e
commit 3db5da7499
1 changed files with 6 additions and 1 deletions

View File

@ -231,11 +231,16 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
schemas = new LinkedList<>(); schemas = new LinkedList<>();
} }
schemas.add(jsonObject); schemas.add(jsonObject);
} else if (bodyType != null && (bodyType.equalsIgnoreCase(Body.BodyType.WWW_FORM.name()) || bodyType.equalsIgnoreCase(Body.BodyType.FORM_DATA.name()))) { // key-value 类格式 } else if (bodyType != null && bodyType.equalsIgnoreCase(Body.BodyType.WWW_FORM.name())) {
String wwwFormBody = body.optString("wwwFormBody"); String wwwFormBody = body.optString("wwwFormBody");
JSONObject wwwFormObject = JSONUtil.parseObject(wwwFormBody); JSONObject wwwFormObject = JSONUtil.parseObject(wwwFormBody);
JSONObject formData = getformDataProperties(wwwFormObject.optJSONArray("formValues")); JSONObject formData = getformDataProperties(wwwFormObject.optJSONArray("formValues"));
bodyInfo = buildFormDataSchema(formData); bodyInfo = buildFormDataSchema(formData);
} else if (bodyType != null && bodyType.equalsIgnoreCase(Body.BodyType.FORM_DATA.name())) {
String formDataBody = body.optString("formDataBody");
JSONObject formDataObject = JSONUtil.parseObject(formDataBody);
JSONObject formData = getformDataProperties(formDataObject.optJSONArray("formValues"));
bodyInfo = buildFormDataSchema(formData);
} else if (bodyType != null && bodyType.equalsIgnoreCase(Body.BodyType.BINARY.name())) { } else if (bodyType != null && bodyType.equalsIgnoreCase(Body.BodyType.BINARY.name())) {
bodyInfo = buildBinary(); bodyInfo = buildBinary();
} }