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;
|
||||
@Schema(description = "swagger地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String swaggerUrl;
|
||||
@Schema(description = "swagger token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String swaggerToken;
|
||||
@Schema(description = "是否覆盖模块")
|
||||
private Boolean coverModule = false;
|
||||
@Schema(description = "是否同步导入用例")
|
||||
|
|
|
@ -7,4 +7,7 @@ public class SwaggerBasicAuth {
|
|||
private Boolean authSwitch = false;
|
||||
private String userName;
|
||||
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})
|
||||
@Size(min = 1, max = 500, message = "{api_definition_swagger.swagger_url.length_range}", groups = {Created.class, Updated.class})
|
||||
private String swaggerUrl;
|
||||
private String swaggerToken;
|
||||
private String taskId;
|
||||
@Schema(description = "是否覆盖模块")
|
||||
private Boolean coverModule = false;
|
||||
|
|
|
@ -14,6 +14,8 @@ public class ImportRequest {
|
|||
private String projectId;
|
||||
@Schema(description = "导入的swagger地址")
|
||||
private String swaggerUrl;
|
||||
@Schema(description = "导入的swagger token")
|
||||
private String swaggerToken;
|
||||
@Schema(description = "如果是定时任务的时候 需要传入创建人id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String userId;
|
||||
private String versionId; // 新导入选择的版本
|
||||
|
|
|
@ -118,6 +118,16 @@ public class Swagger3ParserApiDefinition extends HttpApiDefinitionImportAbstract
|
|||
authorizationValue.setValue(authValue);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ public class ApiDefinitionScheduleService {
|
|||
basicAuth.setUserName(request.getAuthUsername());
|
||||
basicAuth.setPassword(request.getAuthPassword());
|
||||
basicAuth.setAuthSwitch(request.isAuthSwitch());
|
||||
basicAuth.setToken(request.getSwaggerToken());
|
||||
apiSwagger.setConfig(ApiDataUtils.toJSONString(basicAuth));
|
||||
apiDefinitionSwaggerMapper.insertSelective(apiSwagger);
|
||||
|
||||
|
@ -166,6 +167,7 @@ public class ApiDefinitionScheduleService {
|
|||
apiScheduleDTO.setAuthUsername(basicAuth.getUserName());
|
||||
apiScheduleDTO.setAuthPassword(basicAuth.getPassword());
|
||||
apiScheduleDTO.setAuthSwitch(basicAuth.getAuthSwitch());
|
||||
apiScheduleDTO.setSwaggerToken(basicAuth.getToken());
|
||||
}
|
||||
apiScheduleDTO.setEnable(schedule.getEnable());
|
||||
apiScheduleDTO.setValue(schedule.getValue());
|
||||
|
|
|
@ -237,6 +237,7 @@ export interface ImportApiDefinitionRequest {
|
|||
uniquelyIdentifies?: string;
|
||||
resourceId?: string;
|
||||
swaggerUrl?: string;
|
||||
swaggerToken?: string;
|
||||
moduleId: string;
|
||||
projectId: string;
|
||||
name?: string;
|
||||
|
|
|
@ -157,6 +157,9 @@
|
|||
allow-clear
|
||||
></a-input>
|
||||
</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]">
|
||||
<a-switch v-model:model-value="importForm.authSwitch" type="line" size="small"></a-switch>
|
||||
{{ t('apiTestManagement.basicAuth') }}
|
||||
|
@ -224,6 +227,9 @@
|
|||
allow-clear
|
||||
></a-input>
|
||||
</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]">
|
||||
<a-switch v-model:model-value="importForm.authSwitch" type="line" size="small"></a-switch>
|
||||
{{ t('apiTestManagement.basicAuth') }}
|
||||
|
@ -415,6 +421,7 @@
|
|||
syncMock: true,
|
||||
coverModule: false,
|
||||
swaggerUrl: '',
|
||||
swaggerToken: '',
|
||||
authSwitch: false,
|
||||
authUsername: '',
|
||||
authPassword: '',
|
||||
|
@ -519,6 +526,7 @@
|
|||
protocol: importForm.value.protocol,
|
||||
moduleId: importForm.value.moduleId,
|
||||
swaggerUrl: importForm.value.swaggerUrl,
|
||||
swaggerToken: importForm.value.swaggerToken,
|
||||
authSwitch: importForm.value.authSwitch,
|
||||
authUsername: importForm.value.authUsername,
|
||||
authPassword: importForm.value.authPassword,
|
||||
|
@ -552,6 +560,7 @@
|
|||
protocol: importForm.value.protocol,
|
||||
moduleId: importForm.value.moduleId,
|
||||
swaggerUrl: importForm.value.swaggerUrl,
|
||||
swaggerToken: importForm.value.swaggerToken,
|
||||
authSwitch: importForm.value.authSwitch,
|
||||
authUsername: importForm.value.authUsername,
|
||||
authPassword: importForm.value.authPassword,
|
||||
|
|
Loading…
Reference in New Issue