fix(接口测试): 修复参数和类型不符合的json-schema数据转json错误的缺陷
--bug=1027424 --user=王孝刚 【接口测试】接口请求体关闭 json-schema 后显示的json字符不对 https://www.tapd.cn/55049933/s/1387663
This commit is contained in:
parent
0d1bf7610f
commit
b8d433d35d
|
@ -263,7 +263,7 @@ public class JSONSchemaParser {
|
|||
return JSONUtil.parserObject(value);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return jsonSchema;
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -293,6 +293,7 @@ import { useApiStore } from '@/store';
|
|||
import { buildTree } from 'metersphere-frontend/src/model/NodeTree';
|
||||
import { createMockConfig, getMockApiParams, mockExpectConfig } from '@/api/api-mock';
|
||||
import MockEditDrawer from '@/business/definition/components/mock/MockEditDrawer';
|
||||
import {getUserDefaultApiType} from "metersphere-frontend/src/api/environment";
|
||||
|
||||
const store = useApiStore();
|
||||
export default {
|
||||
|
@ -506,6 +507,9 @@ export default {
|
|||
this.activeDom = 'middle';
|
||||
}
|
||||
}
|
||||
getUserDefaultApiType().then(response => {
|
||||
this.currentProtocol = response.data;
|
||||
})
|
||||
this.getEnv();
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
@ -81,8 +81,13 @@ export default {
|
|||
} else {
|
||||
if (this.item.jsonSchema) {
|
||||
MsConvert.schemaToJsonStr(this.item.jsonSchema, (result) => {
|
||||
if (result === 'Error') {
|
||||
this.body.format = 'JSON-SCHEMA';
|
||||
this.$message.error(this.$t('api_definition.body.json_format_error_tips'));
|
||||
} else {
|
||||
this.$set(this.item, 'value', result);
|
||||
this.$emit('callback', result);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,9 +267,14 @@ export default {
|
|||
} else {
|
||||
if (this.body.jsonSchema) {
|
||||
MsConvert.schemaToJsonStr(this.body.jsonSchema, (result) => {
|
||||
if (result === 'Error') {
|
||||
this.body.format = 'JSON-SCHEMA';
|
||||
this.$message.error(this.$t('api_definition.body.json_format_error_tips'));
|
||||
} else {
|
||||
this.$set(this.body, 'raw', result);
|
||||
this.reloadCodeEdit();
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -202,8 +202,13 @@ export default {
|
|||
} else {
|
||||
if (this.body.jsonSchema) {
|
||||
MsConvert.schemaToJsonStr(this.body.jsonSchema, (result) => {
|
||||
if (result === 'Error') {
|
||||
this.body.format = 'JSON-SCHEMA';
|
||||
this.$message.error(this.$t('api_definition.body.json_format_error_tips'));
|
||||
} else {
|
||||
this.$set(this.body, 'raw', result);
|
||||
this.reloadCodeEdit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,8 +232,13 @@ export default {
|
|||
} else {
|
||||
if (this.body.jsonSchema) {
|
||||
MsConvert.schemaToJsonStr(this.body.jsonSchema, (result) => {
|
||||
if (result === 'Error') {
|
||||
this.body.format = 'JSON-SCHEMA';
|
||||
this.$message.error(this.$t('api_definition.body.json_format_error_tips'));
|
||||
} else {
|
||||
this.$set(this.body, 'raw', result);
|
||||
this.reloadCodeEdit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1037,7 +1037,7 @@ export class ExtractCommon extends ExtractType {
|
|||
this.value = ''; // ${variable}
|
||||
this.expression = undefined;
|
||||
this.description = undefined;
|
||||
this.multipleMatching = undefined;
|
||||
this.multipleMatching = false;
|
||||
this.set(options);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ const message = {
|
|||
'Use cases with the same name and mock expectations will be forcibly overwritten!',
|
||||
body: {
|
||||
json_format_error: 'JSON format error',
|
||||
json_format_error_tips: 'JSON-SCHEMA data does not match the type, please check',
|
||||
},
|
||||
case_name: 'Case name',
|
||||
case_no_permission: 'No permission to edit case',
|
||||
|
|
|
@ -21,6 +21,7 @@ const message = {
|
|||
copy_data_from_other_version_tips: '名称相同的用例和Mock期望会进行强制覆盖!',
|
||||
body: {
|
||||
json_format_error: 'JSON格式错误',
|
||||
json_format_error_tips: 'JSON-SCHEMA数据和类型不符合,请检查',
|
||||
},
|
||||
case_name: '用例名称',
|
||||
case_no_permission: '无编辑用例的权限',
|
||||
|
|
|
@ -21,6 +21,7 @@ const message = {
|
|||
copy_data_from_other_version_tips: '名稱相同的用例和Mock期望會進行強制覆蓋!',
|
||||
body: {
|
||||
json_format_error: 'JSON格式錯誤',
|
||||
json_format_error_tips: 'JSON-SCHEMA數據和類型不符合,請檢查',
|
||||
},
|
||||
case_name: '用例名稱',
|
||||
case_no_permission: '無編輯用例的權限',
|
||||
|
|
|
@ -283,6 +283,8 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
|
|||
try {
|
||||
Number number1 = NumberUtils.createBigDecimal(v1);
|
||||
Number number2 = NumberUtils.createBigDecimal(v2);
|
||||
log.info("number1: " + number1 + " number2: " + number2);
|
||||
log.info("number1.equals(number2): " + number1.equals(number2));
|
||||
return number1.equals(number2);
|
||||
} catch (Exception e) {
|
||||
return StringUtils.equals(v1, v2);
|
||||
|
@ -291,8 +293,8 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
|
|||
|
||||
private static boolean valueNotEquals(String v1, String v2) {
|
||||
try {
|
||||
Number number1 = NumberUtils.createNumber(v1);
|
||||
Number number2 = NumberUtils.createNumber(v2);
|
||||
Number number1 = NumberUtils.createBigDecimal(v1);
|
||||
Number number2 = NumberUtils.createBigDecimal(v2);
|
||||
return !number1.equals(number2);
|
||||
} catch (Exception e) {
|
||||
return !StringUtils.equals(v1, v2);
|
||||
|
|
Loading…
Reference in New Issue