fix(接口测试): 修复接口参数角标不显示的缺陷
--bug=1031018 --user=王孝刚 【接口测试】场景详情-复制步骤或者接口列表导入复制case-步骤认证配置选择Basic Auth和Digest Auth保存场景-认证配置tab页角标未更 https://www.tapd.cn/55049933/s/1419518 --bug=1031015 --user=王孝刚 【接口测试】场景详情-复制case-请求体json和form-data下都有数据-清空json-请求体角标不显示了 https://www.tapd.cn/55049933/s/1419545
This commit is contained in:
parent
ebbb9c3a56
commit
0acf8d98a8
|
@ -40,6 +40,8 @@ import org.json.JSONObject;
|
|||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
@ -107,17 +109,28 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
}
|
||||
}
|
||||
// 设置 query 参数
|
||||
StringBuilder pathBuilder = new StringBuilder();
|
||||
pathBuilder.append(request.getSwaggerUrl());
|
||||
if (!request.getSwaggerUrl().contains("?")) {
|
||||
pathBuilder.append("?");
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(request.getArguments())) {
|
||||
for (KeyValue keyValue : request.getArguments()) {
|
||||
if (StringUtils.isNotBlank(keyValue.getName())) {
|
||||
AuthorizationValue authorizationValue = new AuthorizationValue();
|
||||
authorizationValue.setType("query");
|
||||
authorizationValue.setKeyName(keyValue.getName());
|
||||
authorizationValue.setValue(keyValue.getValue());
|
||||
try {
|
||||
authorizationValue.setValue(keyValue.isUrlEncode() ? URLEncoder.encode(keyValue.getValue(), StandardCharsets.UTF_8) : keyValue.getValue());
|
||||
} catch (Exception e) {
|
||||
LogUtil.info("swagger3 url encode error: " + e);
|
||||
}
|
||||
pathBuilder.append(keyValue.getName()).append("=").append(authorizationValue.getValue()).append("&");
|
||||
auths.add(authorizationValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
request.setSwaggerUrl(pathBuilder.substring(0, pathBuilder.length() - 1));
|
||||
return CollectionUtils.size(auths) == 0 ? null : auths;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
:expand-all-params="expandAllParams"
|
||||
:scenario-definition="scenarioDefinition"
|
||||
@editScenarioAdvance="editScenarioAdvance"
|
||||
@bodyReload="reloadBody"
|
||||
:param-columns="apiJsonSchemaShowColumns"
|
||||
:need-mock="needMock"
|
||||
lang="zh_CN"
|
||||
|
@ -141,6 +142,9 @@ export default {
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
reloadBody() {
|
||||
this.$emit('headersChange');
|
||||
},
|
||||
refreshApiParamsField() {
|
||||
this.apiJsonSchemaShowColumns = getShowFields(this.storageKey);
|
||||
},
|
||||
|
|
|
@ -648,6 +648,7 @@ export default {
|
|||
this.$emit('reloadItems');
|
||||
},
|
||||
reloadItems() {
|
||||
this.$emit('bodyReload');
|
||||
if (!this.hidden) {
|
||||
this.hidden = !this.hidden;
|
||||
this.$nextTick(() => {
|
||||
|
|
|
@ -125,6 +125,7 @@ export default {
|
|||
this.authConfig = authManager;
|
||||
this.request.authManager = this.authConfig;
|
||||
}
|
||||
this.$emit('headersChange');
|
||||
},
|
||||
initData() {
|
||||
if (this.request.hashTree) {
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
:body="body"
|
||||
:scenario-definition="scenarioDefinition"
|
||||
@editScenarioAdvance="editScenarioAdvance"
|
||||
@headersChange="reloadBody"
|
||||
:is-read-only="isReadOnly"
|
||||
ref="jsonCodeEdit" />
|
||||
<ms-code-edit
|
||||
|
@ -195,6 +196,9 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
reloadBody() {
|
||||
this.$emit('headersChange');
|
||||
},
|
||||
refreshApiParamsField() {
|
||||
this.reloadedApiVariable = false;
|
||||
this.$nextTick(() => {
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
</el-tab-pane>
|
||||
|
||||
<!-- 认证配置 -->
|
||||
<el-tab-pane :label="$t('api_test.definition.request.auth_config')" name="authConfig">
|
||||
<el-tab-pane v-if="isBodyShow" :label="$t('api_test.definition.request.auth_config')" name="authConfig">
|
||||
<el-tooltip
|
||||
class="item-tabs"
|
||||
effect="dark"
|
||||
|
@ -150,7 +150,7 @@
|
|||
</span>
|
||||
</el-tooltip>
|
||||
|
||||
<ms-api-auth-config :is-read-only="isReadOnly" :request="request" v-if="activeName === 'authConfig'" />
|
||||
<ms-api-auth-config :is-read-only="isReadOnly" :request="request" v-if="activeName === 'authConfig'" @headersChange="reloadBody"/>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane :label="$t('api_test.definition.request.other_config')" name="advancedConfig">
|
||||
|
@ -371,35 +371,15 @@ export default {
|
|||
return this.request.authManager && this.request.authManager.verification !== 'No Auth';
|
||||
},
|
||||
showSubscript() {
|
||||
if (!this.request.body || !this.request.body.type) {
|
||||
return false;
|
||||
}
|
||||
switch (this.request.body.type) {
|
||||
case BODY_TYPE.RAW:
|
||||
case BODY_TYPE.XML:
|
||||
return this.request.body.raw;
|
||||
case BODY_TYPE.BINARY:
|
||||
return (
|
||||
this.request.body.binary &&
|
||||
this.request.body.binary.length > 0 &&
|
||||
this.request.body.binary[0].files &&
|
||||
this.request.body.binary[0].files.length > 0
|
||||
);
|
||||
case BODY_TYPE.KV:
|
||||
return this.request.body.kvs && this.request.body.kvs.length > 1;
|
||||
case BODY_TYPE.JSON: {
|
||||
if (this.request.body.format && this.request.body.format === 'JSON-SCHEMA') {
|
||||
return this.request.body.jsonSchema;
|
||||
} else {
|
||||
return this.request.body.raw;
|
||||
}
|
||||
}
|
||||
case BODY_TYPE.FORM_DATA:
|
||||
case BODY_TYPE.WWW_FORM:
|
||||
return this.request.body.kvs && this.request.body.kvs.length > 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
(this.request.body.kvs && this.request.body.kvs.length > 1) ||
|
||||
this.request.body.raw ||
|
||||
(this.request.body.binary &&
|
||||
this.request.body.binary.length > 0 &&
|
||||
this.request.body.binary[0].files &&
|
||||
this.request.body.binary[0].files.length > 0) ||
|
||||
(this.request.body.jsonSchema && this.request.body.jsonSchema.properties && Object.keys(this.request.body.jsonSchema.properties).length !== 0)
|
||||
);
|
||||
},
|
||||
refreshApiParamsField() {
|
||||
let oldActiveName = this.activeName;
|
||||
|
|
Loading…
Reference in New Issue