feat: API数据源支持输入jsonpath

This commit is contained in:
taojinlong 2023-01-17 17:38:36 +08:00
parent cde7bae4a6
commit 444d7c52ac
2 changed files with 6 additions and 2 deletions

View File

@ -407,7 +407,7 @@ public class ApiProvider extends Provider {
List<String[]> dataList = new LinkedList<>();
if(apiDefinition.isUseJsonPath()){
List<LinkedHashMap> currentData = new ArrayList<>();
Object object = JsonPath.read(result, apiDefinition.getDataPath());
Object object = JsonPath.read(result, apiDefinition.getJsonPath());
if (object instanceof List) {
currentData = (List<LinkedHashMap>) object;
} else {

View File

@ -538,9 +538,9 @@
<el-form-item
:label="$t('datasource.isUseJsonPath')"
prop="url"
>
<el-input
:disabled="!apiItem.useJsonPath"
v-model="apiItem.jsonPath"
:placeholder="$t('datasource.jsonpath_info')"
class="input-with-select"
@ -1103,6 +1103,10 @@ export default {
this.$message.error(i18n.t('datasource.has_repeat_name'))
return
}
if (this.apiItem.useJsonPath && !this.apiItem.jsonPath) {
this.$message.error(i18n.t('datasource.please_input_dataPath'))
return
}
this.$refs.apiItemBasicInfo.validate((valid) => {
if (valid) {
const data = Base64.encode(JSON.stringify(this.apiItem))