refactor(接口定义): 增加JSON-SCHEMA开关
This commit is contained in:
parent
02c99498e7
commit
554af29606
|
@ -57,7 +57,7 @@ public class Body {
|
||||||
if (!this.isJson()) {
|
if (!this.isJson()) {
|
||||||
sampler.setPostBodyRaw(true);
|
sampler.setPostBodyRaw(true);
|
||||||
} else {
|
} else {
|
||||||
if (this.getJsonSchema() != null) {
|
if (StringUtils.isNotEmpty(this.format) && this.format.equals("JSON-SCHEMA") && this.getJsonSchema() != null) {
|
||||||
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
|
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.api.jmeter;
|
package io.metersphere.api.jmeter;
|
||||||
|
|
||||||
|
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||||
import io.metersphere.api.service.*;
|
import io.metersphere.api.service.*;
|
||||||
import io.metersphere.base.domain.ApiScenarioReport;
|
import io.metersphere.base.domain.ApiScenarioReport;
|
||||||
import io.metersphere.base.domain.ApiTestReport;
|
import io.metersphere.base.domain.ApiTestReport;
|
||||||
|
@ -336,7 +337,11 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
||||||
String start = "RPC Protocol: ";
|
String start = "RPC Protocol: ";
|
||||||
String end = "://";
|
String end = "://";
|
||||||
if (StringUtils.contains(body, start)) {
|
if (StringUtils.contains(body, start)) {
|
||||||
return StringUtils.substringBetween(body, start, end).toUpperCase();
|
String protocol = StringUtils.substringBetween(body, start, end);
|
||||||
|
if (StringUtils.isNotEmpty(protocol)) {
|
||||||
|
return protocol.toUpperCase();
|
||||||
|
}
|
||||||
|
return RequestType.DUBBO;
|
||||||
} else {
|
} else {
|
||||||
// Http Method
|
// Http Method
|
||||||
String method = StringUtils.substringBefore(body, " ");
|
String method = StringUtils.substringBefore(body, " ");
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"/>
|
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"/>
|
||||||
|
|
||||||
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||||
<ms-request-result-tail :response="request.requestResult" ref="runResult"/>
|
<ms-request-result-tail :currentProtocol="request.protocol" :response="request.requestResult" ref="runResult"/>
|
||||||
|
|
||||||
<!-- 保存操作 -->
|
<!-- 保存操作 -->
|
||||||
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
|
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
|
||||||
|
|
|
@ -41,7 +41,11 @@
|
||||||
v-if="body.type == 'WWW_FORM'"/>
|
v-if="body.type == 'WWW_FORM'"/>
|
||||||
|
|
||||||
<div v-if="body.type == 'JSON'">
|
<div v-if="body.type == 'JSON'">
|
||||||
<ms-json-code-edit :body="body" ref="jsonCodeEdit"/>
|
<div style="padding: 10px">
|
||||||
|
<el-switch active-text="JSON-SCHEMA" v-model="body.format" active-value="JSON-SCHEMA"/>
|
||||||
|
</div>
|
||||||
|
<ms-json-code-edit v-if="body.format==='JSON-SCHEMA'" :body="body" ref="jsonCodeEdit"/>
|
||||||
|
<ms-code-edit v-else :read-only="isReadOnly" height="400px" :data.sync="body.raw" :modes="modes" :mode="'json'" ref="codeEdit"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ms-body" v-if="body.type == 'XML'">
|
<div class="ms-body" v-if="body.type == 'XML'">
|
||||||
|
@ -101,10 +105,10 @@
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
type: BODY_TYPE,
|
type: BODY_TYPE,
|
||||||
modes: ['text', 'json', 'xml', 'html']
|
modes: ['text', 'json', 'xml', 'html'],
|
||||||
|
jsonSchema: "JSON",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
modeChange(mode) {
|
modeChange(mode) {
|
||||||
switch (this.body.type) {
|
switch (this.body.type) {
|
||||||
|
@ -148,12 +152,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jsonChange(json) {
|
|
||||||
this.body.raw = JSON.stringify(json);
|
|
||||||
},
|
|
||||||
jsonError(e) {
|
|
||||||
this.$error(e);
|
|
||||||
},
|
|
||||||
batchAdd() {
|
batchAdd() {
|
||||||
this.$refs.batchAddParameter.open();
|
this.$refs.batchAddParameter.open();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue