refactor(接口定义): 增加JSON-SCHEMA开关
This commit is contained in:
parent
02c99498e7
commit
554af29606
|
@ -57,7 +57,7 @@ public class Body {
|
|||
if (!this.isJson()) {
|
||||
sampler.setPostBodyRaw(true);
|
||||
} 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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.jmeter;
|
||||
|
||||
import io.metersphere.api.dto.scenario.request.RequestType;
|
||||
import io.metersphere.api.service.*;
|
||||
import io.metersphere.base.domain.ApiScenarioReport;
|
||||
import io.metersphere.base.domain.ApiTestReport;
|
||||
|
@ -336,7 +337,11 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
String start = "RPC Protocol: ";
|
||||
String end = "://";
|
||||
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 {
|
||||
// Http Method
|
||||
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'"/>
|
||||
|
||||
<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">
|
||||
|
|
|
@ -41,7 +41,11 @@
|
|||
v-if="body.type == 'WWW_FORM'"/>
|
||||
|
||||
<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 class="ms-body" v-if="body.type == 'XML'">
|
||||
|
@ -101,10 +105,10 @@
|
|||
data() {
|
||||
return {
|
||||
type: BODY_TYPE,
|
||||
modes: ['text', 'json', 'xml', 'html']
|
||||
modes: ['text', 'json', 'xml', 'html'],
|
||||
jsonSchema: "JSON",
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
modeChange(mode) {
|
||||
switch (this.body.type) {
|
||||
|
@ -148,12 +152,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
jsonChange(json) {
|
||||
this.body.raw = JSON.stringify(json);
|
||||
},
|
||||
jsonError(e) {
|
||||
this.$error(e);
|
||||
},
|
||||
batchAdd() {
|
||||
this.$refs.batchAddParameter.open();
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue