fix (接口定义): 操作历史显示问题修复
--bug=1007196 --user=赵勇 【接口定义】-变更历史详情显示优化 https://www.tapd.cn/55049933/s/1056520
This commit is contained in:
parent
fe1dc1d9d6
commit
08969f31b4
|
@ -176,11 +176,15 @@ public class JsonDiff {
|
|||
if (instruction.oper == Oper.INSERT || instruction.oper == Oper.DELETE) {
|
||||
applyPartial(origEl, instruction, value);
|
||||
} else if (instruction.isIndexed()) {
|
||||
if (!origEl.isJsonArray()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (value.isJsonPrimitive()) {
|
||||
((JzonArray) origEl).set(instruction.index, value);
|
||||
} else if (origEl.isJsonObject()) {
|
||||
if (value.isJsonPrimitive() || value.isJsonNull()) {
|
||||
((JzonObject) origEl).add(key, value);
|
||||
} else {
|
||||
JzonElement childEl = ((JzonObject) origEl).get(key);
|
||||
apply(childEl, value);
|
||||
}
|
||||
} else {
|
||||
if (((JzonArray) origEl).size() <= instruction.index) {
|
||||
throw new IllegalArgumentException("Wrong index " + instruction.index + " for " + origEl);
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
<!--请求体-->
|
||||
<el-tab-pane :label="$t('api_test.request.body')" name="body" v-if="request.body && (request.body.jsonSchema ||request.body.raw_1 || request.body.raw_2 )">
|
||||
<el-radio-group v-model="activeBody" size="mini">
|
||||
<el-radio-button label="json"/>
|
||||
<el-radio-button label="raw"/>
|
||||
<el-radio-button label="form"/>
|
||||
<el-radio-button label="json" v-if="request.body.jsonSchema"/>
|
||||
<el-radio-button label="raw" v-if="request.body.raw_1 || request.body.raw_2"/>
|
||||
<el-radio-button label="form" v-if="request.body.form"/>
|
||||
</el-radio-group>
|
||||
<ms-json-code-edit :body="request.body" ref="jsonCodeEdit" v-if="activeBody === 'json'"/>
|
||||
<pre v-html="getDiff(request.body.raw_2,request.body.raw_1)" v-if="activeBody === 'raw'"></pre>
|
||||
|
@ -99,34 +99,15 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
if (this.request.header) {
|
||||
this.activeName = "headers";
|
||||
} else if (this.request.query) {
|
||||
this.activeName = "parameters";
|
||||
} else if (this.request.rest) {
|
||||
this.activeName = "rest";
|
||||
} else if (this.request.body && (this.request.body.jsonSchema || this.request.body.form || this.request.body.raw_1 || this.request.body.raw_2)) {
|
||||
this.activeName = "body";
|
||||
if (this.request.body.jsonSchema) {
|
||||
this.activeBody = "json";
|
||||
}
|
||||
if (this.request.body.form) {
|
||||
this.activeBody = "form";
|
||||
}
|
||||
if (this.request.body.raw_1 || this.request.body.raw_2) {
|
||||
this.activeBody = "raw";
|
||||
}
|
||||
} else if (this.request.body_config) {
|
||||
this.activeName = "advancedConfig";
|
||||
} else if (this.request.body_auth) {
|
||||
this.activeName = "authConfig";
|
||||
} else if (this.request.statusCode) {
|
||||
this.activeName = "statusCode";
|
||||
}
|
||||
this.reloadCodeEdit();
|
||||
this.active();
|
||||
},
|
||||
watch: {
|
||||
'request.headerId'() {
|
||||
this.active();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
active() {
|
||||
if (this.request.header) {
|
||||
this.activeName = "headers";
|
||||
} else if (this.request.query) {
|
||||
|
@ -151,10 +132,19 @@ export default {
|
|||
} else if (this.request.statusCode) {
|
||||
this.activeName = "statusCode";
|
||||
}
|
||||
this.reloadCodeEdit();
|
||||
if (this.request.body && (this.request.body.jsonSchema || this.request.body.form || this.request.body.raw_1 || this.request.body.raw_2)) {
|
||||
if (this.request.body.jsonSchema) {
|
||||
this.activeBody = "json";
|
||||
}
|
||||
if (this.request.body.form) {
|
||||
this.activeBody = "form";
|
||||
}
|
||||
if (this.request.body.raw_1 || this.request.body.raw_2) {
|
||||
this.activeBody = "raw";
|
||||
}
|
||||
}
|
||||
this.reloadCodeEdit();
|
||||
},
|
||||
methods: {
|
||||
getDiff(v1, v2) {
|
||||
let delta = jsondiffpatch.diff(v1, v2);
|
||||
return formattersHtml.format(delta, v1);
|
||||
|
|
Loading…
Reference in New Issue