fix(接口测试): curl 导入xml 及接口调试新建请求修复
--bug=1047024 --user=白奇 【接口测试】场景自定义请求curl导入xml请求类型-导入后请求体无数据 https://www.tapd.cn/55049933/s/1584459
This commit is contained in:
parent
3f82af4eb3
commit
67b86d4487
|
@ -468,7 +468,7 @@ export interface CurlParseResult {
|
||||||
method: RequestMethods | string;
|
method: RequestMethods | string;
|
||||||
url: string;
|
url: string;
|
||||||
headers: Record<string, any>;
|
headers: Record<string, any>;
|
||||||
body: Record<string, any>;
|
body: Record<string, any> | string;
|
||||||
bodyType: RequestBodyFormat;
|
bodyType: RequestBodyFormat;
|
||||||
queryParams: Record<string, any>;
|
queryParams: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
@input="() => (isUrlError = false)"
|
@input="() => (isUrlError = false)"
|
||||||
@change="handleUrlChange"
|
@change="handleUrlChange"
|
||||||
>
|
>
|
||||||
<template v-if="hasAnyPermission(['PROJECT_API_DEBUG:READ+IMPORT'])" #suffix>
|
<template v-if="!props.isDefinition" #suffix>
|
||||||
<MsIcon
|
<MsIcon
|
||||||
type="icon-icon_curl"
|
type="icon-icon_curl"
|
||||||
:size="18"
|
:size="18"
|
||||||
|
|
|
@ -280,7 +280,7 @@ export function filterAssertions(assertionConfig: ExecuteAssertionConfig, isExec
|
||||||
* @param bodyType body 类型
|
* @param bodyType body 类型
|
||||||
* @param body body 参数对象
|
* @param body body 参数对象
|
||||||
*/
|
*/
|
||||||
export function parseCurlBody(bodyType: RequestBodyFormat, body: Record<string, any>) {
|
export function parseCurlBody(bodyType: RequestBodyFormat, body: Record<string, any> | string) {
|
||||||
const requestBody = cloneDeep(defaultBodyParams);
|
const requestBody = cloneDeep(defaultBodyParams);
|
||||||
switch (bodyType) {
|
switch (bodyType) {
|
||||||
case RequestBodyFormat.JSON:
|
case RequestBodyFormat.JSON:
|
||||||
|
@ -291,6 +291,13 @@ export function parseCurlBody(bodyType: RequestBodyFormat, body: Record<string,
|
||||||
jsonValue: JSON.stringify(body),
|
jsonValue: JSON.stringify(body),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
case RequestBodyFormat.XML:
|
||||||
|
requestBody.bodyType = bodyType;
|
||||||
|
requestBody.xmlBody = {
|
||||||
|
...cloneDeep(defaultBodyParams.xmlBody),
|
||||||
|
value: body as string,
|
||||||
|
};
|
||||||
|
break;
|
||||||
case RequestBodyFormat.FORM_DATA:
|
case RequestBodyFormat.FORM_DATA:
|
||||||
requestBody.bodyType = bodyType;
|
requestBody.bodyType = bodyType;
|
||||||
requestBody.formDataBody = {
|
requestBody.formDataBody = {
|
||||||
|
@ -298,7 +305,7 @@ export function parseCurlBody(bodyType: RequestBodyFormat, body: Record<string,
|
||||||
formValues: Object.keys(body).map((e) => ({
|
formValues: Object.keys(body).map((e) => ({
|
||||||
...defaultBodyParamsItem,
|
...defaultBodyParamsItem,
|
||||||
key: e,
|
key: e,
|
||||||
value: body[e],
|
value: (body as Record<string, any>)[e],
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
@ -309,7 +316,7 @@ export function parseCurlBody(bodyType: RequestBodyFormat, body: Record<string,
|
||||||
formValues: Object.keys(body).map((e) => ({
|
formValues: Object.keys(body).map((e) => ({
|
||||||
...defaultBodyParamsItem,
|
...defaultBodyParamsItem,
|
||||||
key: e,
|
key: e,
|
||||||
value: body[e],
|
value: (body as Record<string, any>)[e],
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="flex h-full flex-col p-[12px_16px]">
|
<div class="flex h-full flex-col p-[12px_16px]">
|
||||||
<div class="mb-[8px] flex items-center gap-[8px]">
|
<div class="mb-[8px] flex items-center gap-[8px]">
|
||||||
<a-input v-model:model-value="moduleKeyword" :placeholder="t('apiTestDebug.searchTip')" allow-clear />
|
<a-input v-model:model-value="moduleKeyword" :placeholder="t('apiTestDebug.searchTip')" allow-clear />
|
||||||
<a-button v-permission="['PROJECT_API_DEBUG:READ+ADD']" type="primary">
|
<a-button v-permission="['PROJECT_API_DEBUG:READ+ADD']" type="primary" @click="emit('newApi')">
|
||||||
{{ t('apiTestDebug.newApi') }}
|
{{ t('apiTestDebug.newApi') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue