fix(自定义代码片段): 从API定义导入,自动生成的脚本报错
--bug=1007475 --user=lyh 【接口测试】前置脚本-从API定义导入,自动生成的脚本报错了 https://www.tapd.cn/55049933/s/1061715
This commit is contained in:
parent
e48d9d99d2
commit
ac5ff17af5
|
@ -143,11 +143,10 @@ function _beanshellTemplate(obj) {
|
||||||
let {requestHeaders = new Map(), requestBody = "", requestPath = "/",
|
let {requestHeaders = new Map(), requestBody = "", requestPath = "/",
|
||||||
requestMethod = "GET", protocol = "http", requestArguments = new Map(), domain = "", port = ""} = obj;
|
requestMethod = "GET", protocol = "http", requestArguments = new Map(), domain = "", port = ""} = obj;
|
||||||
let uri = `new URIBuilder()
|
let uri = `new URIBuilder()
|
||||||
.setScheme("${protocol}")
|
.setScheme("${protocol}")
|
||||||
.setHost("${domain}")
|
.setHost("${domain}")
|
||||||
.setPort(${port}) // int类型端口
|
.setPath("${requestPath}")
|
||||||
.setPath("${requestPath}")
|
`;
|
||||||
`;
|
|
||||||
// http 请求类型
|
// http 请求类型
|
||||||
let method = requestMethod.toLowerCase().replace(/^\S/, s => s.toUpperCase());
|
let method = requestMethod.toLowerCase().replace(/^\S/, s => s.toUpperCase());
|
||||||
let httpMethodCode = `Http${method} request = new Http${method}(uri);`;
|
let httpMethodCode = `Http${method} request = new Http${method}(uri);`;
|
||||||
|
@ -155,7 +154,15 @@ function _beanshellTemplate(obj) {
|
||||||
for (let [k, v] of requestArguments) {
|
for (let [k, v] of requestArguments) {
|
||||||
uri = uri + `.setParameter("${k}", "${v}")`;
|
uri = uri + `.setParameter("${k}", "${v}")`;
|
||||||
}
|
}
|
||||||
uri = uri + ".build();";
|
if (port) {
|
||||||
|
uri += `.setPort(${port}) // int类型端口
|
||||||
|
`;
|
||||||
|
uri += ` .build();`;
|
||||||
|
} else {
|
||||||
|
uri += `// .setPort(${port}) // int类型端口
|
||||||
|
`;
|
||||||
|
uri += ` .build();`;
|
||||||
|
}
|
||||||
// 设置请求头
|
// 设置请求头
|
||||||
let setHeader = "";
|
let setHeader = "";
|
||||||
for (let [k, v] of requestHeaders) {
|
for (let [k, v] of requestHeaders) {
|
||||||
|
|
Loading…
Reference in New Issue