feat(接口测试): swagger导入增加token配置
--story=1016360 --user=宋天阳 【Bug转需求】【接口测试】导入DataEase接口-swagger格式-url-导入失败 https://www.tapd.cn/55049933/s/1580083
This commit is contained in:
parent
c93e971b86
commit
75f9488ba3
|
@ -17,6 +17,8 @@ public class ApiScheduleDTO {
|
||||||
private String moduleId;
|
private String moduleId;
|
||||||
@Schema(description = "swagger地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "swagger地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private String swaggerUrl;
|
private String swaggerUrl;
|
||||||
|
@Schema(description = "swagger token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private String swaggerToken;
|
||||||
@Schema(description = "是否覆盖模块")
|
@Schema(description = "是否覆盖模块")
|
||||||
private Boolean coverModule = false;
|
private Boolean coverModule = false;
|
||||||
@Schema(description = "是否同步导入用例")
|
@Schema(description = "是否同步导入用例")
|
||||||
|
|
|
@ -7,4 +7,7 @@ public class SwaggerBasicAuth {
|
||||||
private Boolean authSwitch = false;
|
private Boolean authSwitch = false;
|
||||||
private String userName;
|
private String userName;
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
//新增token设置。放在这里也是因为token是身份验证的一种。
|
||||||
|
private String token;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class ApiScheduleRequest {
|
||||||
@NotBlank(message = "{api_definition_swagger.swagger_url.not_blank}", groups = {Created.class, Updated.class})
|
@NotBlank(message = "{api_definition_swagger.swagger_url.not_blank}", groups = {Created.class, Updated.class})
|
||||||
@Size(min = 1, max = 500, message = "{api_definition_swagger.swagger_url.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 500, message = "{api_definition_swagger.swagger_url.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String swaggerUrl;
|
private String swaggerUrl;
|
||||||
|
private String swaggerToken;
|
||||||
private String taskId;
|
private String taskId;
|
||||||
@Schema(description = "是否覆盖模块")
|
@Schema(description = "是否覆盖模块")
|
||||||
private Boolean coverModule = false;
|
private Boolean coverModule = false;
|
||||||
|
|
|
@ -14,6 +14,8 @@ public class ImportRequest {
|
||||||
private String projectId;
|
private String projectId;
|
||||||
@Schema(description = "导入的swagger地址")
|
@Schema(description = "导入的swagger地址")
|
||||||
private String swaggerUrl;
|
private String swaggerUrl;
|
||||||
|
@Schema(description = "导入的swagger token")
|
||||||
|
private String swaggerToken;
|
||||||
@Schema(description = "如果是定时任务的时候 需要传入创建人id", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "如果是定时任务的时候 需要传入创建人id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private String userId;
|
private String userId;
|
||||||
private String versionId; // 新导入选择的版本
|
private String versionId; // 新导入选择的版本
|
||||||
|
|
|
@ -118,6 +118,16 @@ public class Swagger3ParserApiDefinition extends HttpApiDefinitionImportAbstract
|
||||||
authorizationValue.setValue(authValue);
|
authorizationValue.setValue(authValue);
|
||||||
auths.add(authorizationValue);
|
auths.add(authorizationValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置 headers
|
||||||
|
if (StringUtils.isNotBlank(request.getSwaggerToken())) {
|
||||||
|
AuthorizationValue authorizationValue = new AuthorizationValue();
|
||||||
|
authorizationValue.setType(HEADER);
|
||||||
|
authorizationValue.setKeyName("token");
|
||||||
|
authorizationValue.setValue(request.getSwaggerToken());
|
||||||
|
auths.add(authorizationValue);
|
||||||
|
}
|
||||||
|
|
||||||
return CollectionUtils.size(auths) == 0 ? null : auths;
|
return CollectionUtils.size(auths) == 0 ? null : auths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class ApiDefinitionScheduleService {
|
||||||
basicAuth.setUserName(request.getAuthUsername());
|
basicAuth.setUserName(request.getAuthUsername());
|
||||||
basicAuth.setPassword(request.getAuthPassword());
|
basicAuth.setPassword(request.getAuthPassword());
|
||||||
basicAuth.setAuthSwitch(request.isAuthSwitch());
|
basicAuth.setAuthSwitch(request.isAuthSwitch());
|
||||||
|
basicAuth.setToken(request.getSwaggerToken());
|
||||||
apiSwagger.setConfig(ApiDataUtils.toJSONString(basicAuth));
|
apiSwagger.setConfig(ApiDataUtils.toJSONString(basicAuth));
|
||||||
apiDefinitionSwaggerMapper.insertSelective(apiSwagger);
|
apiDefinitionSwaggerMapper.insertSelective(apiSwagger);
|
||||||
|
|
||||||
|
@ -166,6 +167,7 @@ public class ApiDefinitionScheduleService {
|
||||||
apiScheduleDTO.setAuthUsername(basicAuth.getUserName());
|
apiScheduleDTO.setAuthUsername(basicAuth.getUserName());
|
||||||
apiScheduleDTO.setAuthPassword(basicAuth.getPassword());
|
apiScheduleDTO.setAuthPassword(basicAuth.getPassword());
|
||||||
apiScheduleDTO.setAuthSwitch(basicAuth.getAuthSwitch());
|
apiScheduleDTO.setAuthSwitch(basicAuth.getAuthSwitch());
|
||||||
|
apiScheduleDTO.setSwaggerToken(basicAuth.getToken());
|
||||||
}
|
}
|
||||||
apiScheduleDTO.setEnable(schedule.getEnable());
|
apiScheduleDTO.setEnable(schedule.getEnable());
|
||||||
apiScheduleDTO.setValue(schedule.getValue());
|
apiScheduleDTO.setValue(schedule.getValue());
|
||||||
|
|
|
@ -237,6 +237,7 @@ export interface ImportApiDefinitionRequest {
|
||||||
uniquelyIdentifies?: string;
|
uniquelyIdentifies?: string;
|
||||||
resourceId?: string;
|
resourceId?: string;
|
||||||
swaggerUrl?: string;
|
swaggerUrl?: string;
|
||||||
|
swaggerToken?: string;
|
||||||
moduleId: string;
|
moduleId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|
|
@ -157,6 +157,9 @@
|
||||||
allow-clear
|
allow-clear
|
||||||
></a-input>
|
></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item field="token" label="token" asterisk-position="end">
|
||||||
|
<a-input v-model:model-value="importForm.swaggerToken" class="w-[700px]" allow-clear></a-input>
|
||||||
|
</a-form-item>
|
||||||
<div class="mb-[16px] flex items-center gap-[8px]">
|
<div class="mb-[16px] flex items-center gap-[8px]">
|
||||||
<a-switch v-model:model-value="importForm.authSwitch" type="line" size="small"></a-switch>
|
<a-switch v-model:model-value="importForm.authSwitch" type="line" size="small"></a-switch>
|
||||||
{{ t('apiTestManagement.basicAuth') }}
|
{{ t('apiTestManagement.basicAuth') }}
|
||||||
|
@ -224,6 +227,9 @@
|
||||||
allow-clear
|
allow-clear
|
||||||
></a-input>
|
></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item field="token" label="token" asterisk-position="end">
|
||||||
|
<a-input v-model:model-value="importForm.swaggerToken" class="w-[700px]" allow-clear></a-input>
|
||||||
|
</a-form-item>
|
||||||
<div class="mb-[16px] flex items-center gap-[8px]">
|
<div class="mb-[16px] flex items-center gap-[8px]">
|
||||||
<a-switch v-model:model-value="importForm.authSwitch" type="line" size="small"></a-switch>
|
<a-switch v-model:model-value="importForm.authSwitch" type="line" size="small"></a-switch>
|
||||||
{{ t('apiTestManagement.basicAuth') }}
|
{{ t('apiTestManagement.basicAuth') }}
|
||||||
|
@ -415,6 +421,7 @@
|
||||||
syncMock: true,
|
syncMock: true,
|
||||||
coverModule: false,
|
coverModule: false,
|
||||||
swaggerUrl: '',
|
swaggerUrl: '',
|
||||||
|
swaggerToken: '',
|
||||||
authSwitch: false,
|
authSwitch: false,
|
||||||
authUsername: '',
|
authUsername: '',
|
||||||
authPassword: '',
|
authPassword: '',
|
||||||
|
@ -519,6 +526,7 @@
|
||||||
protocol: importForm.value.protocol,
|
protocol: importForm.value.protocol,
|
||||||
moduleId: importForm.value.moduleId,
|
moduleId: importForm.value.moduleId,
|
||||||
swaggerUrl: importForm.value.swaggerUrl,
|
swaggerUrl: importForm.value.swaggerUrl,
|
||||||
|
swaggerToken: importForm.value.swaggerToken,
|
||||||
authSwitch: importForm.value.authSwitch,
|
authSwitch: importForm.value.authSwitch,
|
||||||
authUsername: importForm.value.authUsername,
|
authUsername: importForm.value.authUsername,
|
||||||
authPassword: importForm.value.authPassword,
|
authPassword: importForm.value.authPassword,
|
||||||
|
@ -552,6 +560,7 @@
|
||||||
protocol: importForm.value.protocol,
|
protocol: importForm.value.protocol,
|
||||||
moduleId: importForm.value.moduleId,
|
moduleId: importForm.value.moduleId,
|
||||||
swaggerUrl: importForm.value.swaggerUrl,
|
swaggerUrl: importForm.value.swaggerUrl,
|
||||||
|
swaggerToken: importForm.value.swaggerToken,
|
||||||
authSwitch: importForm.value.authSwitch,
|
authSwitch: importForm.value.authSwitch,
|
||||||
authUsername: importForm.value.authUsername,
|
authUsername: importForm.value.authUsername,
|
||||||
authPassword: importForm.value.authPassword,
|
authPassword: importForm.value.authPassword,
|
||||||
|
|
Loading…
Reference in New Issue