diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index e346e718f7..0a39f4909d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1408,13 +1408,15 @@ public class ApiDefinitionService { /*swagger定时导入*/ public void createSchedule(ScheduleRequest request) { - String config = setAuthParams(request); /*保存swaggerUrl*/ SwaggerUrlProject swaggerUrlProject = new SwaggerUrlProject(); BeanUtils.copyBean(swaggerUrlProject, request); swaggerUrlProject.setId(UUID.randomUUID().toString()); // 设置鉴权信息 - swaggerUrlProject.setConfig(config); + if(request.getHeaders() !=null || request.getArguments() !=null || request.getAuthManager() != null){ + String config = setAuthParams(request); + swaggerUrlProject.setConfig(config); + } scheduleService.addSwaggerUrlSchedule(swaggerUrlProject); request.setResourceId(swaggerUrlProject.getId()); @@ -1435,11 +1437,15 @@ public class ApiDefinitionService { } public void updateSchedule(ScheduleRequest request) { - String config = setAuthParams(request); SwaggerUrlProject swaggerUrlProject = new SwaggerUrlProject(); BeanUtils.copyBean(swaggerUrlProject, request); // 设置鉴权信息 - swaggerUrlProject.setConfig(config); + if(request.getHeaders() !=null || request.getArguments() !=null || request.getAuthManager() != null){ + String config = setAuthParams(request); + swaggerUrlProject.setConfig(config); + }else{ + swaggerUrlProject.setConfig(null); + } scheduleService.updateSwaggerUrlSchedule(swaggerUrlProject); // 只修改表达式和名称 Schedule schedule = new Schedule(); diff --git a/backend/src/main/java/io/metersphere/service/ScheduleService.java b/backend/src/main/java/io/metersphere/service/ScheduleService.java index 25166fb13e..0df93cbf4c 100644 --- a/backend/src/main/java/io/metersphere/service/ScheduleService.java +++ b/backend/src/main/java/io/metersphere/service/ScheduleService.java @@ -64,7 +64,7 @@ public class ScheduleService { } public void updateSwaggerUrlSchedule(SwaggerUrlProject swaggerUrlProject) { - swaggerUrlProjectMapper.updateByPrimaryKeySelective(swaggerUrlProject); + swaggerUrlProjectMapper.updateByPrimaryKeyWithBLOBs(swaggerUrlProject); } public ApiSwaggerUrlDTO selectApiSwaggerUrlDTO(String id) { diff --git a/frontend/src/business/components/api/definition/components/import/ApiImport.vue b/frontend/src/business/components/api/definition/components/import/ApiImport.vue index cb82cee63f..01a8329cb0 100644 --- a/frontend/src/business/components/api/definition/components/import/ApiImport.vue +++ b/frontend/src/business/components/api/definition/components/import/ApiImport.vue @@ -72,7 +72,7 @@ - + @@ -90,7 +90,7 @@
{{$t('api_test.definition.request.auth_config')}}{{$t('api_test.api_import.optional')}}:
- +
- + @@ -239,6 +239,11 @@ export default { currentUser: () => { return getCurrentUser(); }, + changeAuthEnable() { + if(!this.authEnable){ + this.clearAuthInfo(); + } + }, clear() { this.formData.id = null; this.formData.moduleId = null; @@ -279,13 +284,19 @@ export default { this.formData.projectId = getCurrentProjectID(); this.formData.workspaceId = getCurrentWorkspaceId(); this.formData.value = this.formData.rule; - // 设置请求头或 query 参数 - this.formData.headers = this.headers; - this.formData.arguments = this.queryArguments; - // 设置 BaseAuth 参数 - if(this.authConfig.authManager != undefined){ - this.authConfig.authManager.clazzName = TYPE_TO_C.get("AuthManager"); - this.formData.authManager = this.authConfig.authManager; + if(this.authEnable){ + // 设置请求头或 query 参数 + this.formData.headers = this.headers; + this.formData.arguments = this.queryArguments; + // 设置 BaseAuth 参数 + if(this.authConfig.authManager != undefined){ + this.authConfig.authManager.clazzName = TYPE_TO_C.get("AuthManager"); + this.formData.authManager = this.authConfig.authManager; + } + }else { + this.formData.headers = undefined; + this.formData.arguments = undefined; + this.formData.authManager = undefined; } let url = ''; if (this.formData.id) { @@ -300,7 +311,6 @@ export default { this.clear(); }); }, - intervalShortValidate() { if (this.getIntervalTime() < 3 * 60 * 1000) { this.$info(this.$t('schedule.cron_expression_interval_short_error')); @@ -348,7 +358,6 @@ export default { this.authConfig = {hashTree: [], authManager: {}}; this.authEnable = false; } - }, computed: { isTesterPermission() {