feat(接口测试): swagger的url导入支持自定义token
--bug=1046842 --user=宋天阳 【接口测试】导入接口-swagger导入带token-导入解析失败 https://www.tapd.cn/55049933/s/1582539
This commit is contained in:
parent
95209738b0
commit
03bbba5ede
|
@ -121,11 +121,17 @@ public class Swagger3ParserApiDefinition extends HttpApiDefinitionImportAbstract
|
||||||
|
|
||||||
// 设置 headers
|
// 设置 headers
|
||||||
if (StringUtils.isNotBlank(request.getSwaggerToken())) {
|
if (StringUtils.isNotBlank(request.getSwaggerToken())) {
|
||||||
AuthorizationValue authorizationValue = new AuthorizationValue();
|
String[] tokenRows = StringUtils.split(request.getSwaggerToken(), StringUtils.LF);
|
||||||
authorizationValue.setType(HEADER);
|
for (String row : tokenRows) {
|
||||||
authorizationValue.setKeyName("token");
|
String[] tokenArr = StringUtils.split(row, ":");
|
||||||
authorizationValue.setValue(request.getSwaggerToken());
|
if (tokenArr.length == 2) {
|
||||||
auths.add(authorizationValue);
|
AuthorizationValue authorizationValue = new AuthorizationValue();
|
||||||
|
authorizationValue.setType(HEADER);
|
||||||
|
authorizationValue.setKeyName(tokenArr[0]);
|
||||||
|
authorizationValue.setValue(tokenArr[1]);
|
||||||
|
auths.add(authorizationValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CollectionUtils.size(auths) == 0 ? null : auths;
|
return CollectionUtils.size(auths) == 0 ? null : auths;
|
||||||
|
|
|
@ -158,7 +158,12 @@
|
||||||
></a-input>
|
></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item field="token" label="token" asterisk-position="end">
|
<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-textarea
|
||||||
|
v-model:model-value="importForm.swaggerToken"
|
||||||
|
:auto-size="{ minRows: 1 }"
|
||||||
|
class="w-[700px]"
|
||||||
|
allow-clear
|
||||||
|
/>
|
||||||
</a-form-item>
|
</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>
|
||||||
|
@ -228,7 +233,12 @@
|
||||||
></a-input>
|
></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item field="token" label="token" asterisk-position="end">
|
<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-textarea
|
||||||
|
v-model:model-value="importForm.swaggerToken"
|
||||||
|
:auto-size="{ minRows: 1 }"
|
||||||
|
class="w-[700px]"
|
||||||
|
allow-clear
|
||||||
|
/>
|
||||||
</a-form-item>
|
</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>
|
||||||
|
|
Loading…
Reference in New Issue