fix(接口自动化): 请求校验

This commit is contained in:
fit2-zhao 2020-12-15 15:33:50 +08:00
parent e5b007764f
commit 880add8544
7 changed files with 37 additions and 22 deletions

View File

@ -96,6 +96,10 @@
saveApi(saveAs) { saveApi(saveAs) {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
if (valid) { if (valid) {
if(this.httpForm.path.match(/\s/)!=null){
this.$error(this.$t("api_test.definition.request.path_valid_info"));
return false;
}
let bodyFiles = []; let bodyFiles = [];
let path = "/api/definition/create"; let path = "/api/definition/create";
this.setParameter(); this.setParameter();

View File

@ -124,6 +124,10 @@
runTest() { runTest() {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
if (valid) { if (valid) {
if(this.httpForm.path.match(/\s/)!=null){
this.$error(this.$t("api_test.definition.request.path_valid_info"));
return false;
}
this.setParameter(); this.setParameter();
this.$emit('runTest', this.httpForm); this.$emit('runTest', this.httpForm);
} else { } else {
@ -146,6 +150,10 @@
saveApi() { saveApi() {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
if (valid) { if (valid) {
if(this.httpForm.path.match(/\s/)!=null){
this.$error(this.$t("api_test.definition.request.path_valid_info"));
return false;
}
this.setParameter(); this.setParameter();
this.$emit('saveApi', this.httpForm); this.$emit('saveApi', this.httpForm);
} }

View File

@ -90,30 +90,30 @@
</el-form> </el-form>
</div> </div>
<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%"> <!--<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%">-->
<!-- 前置脚本 --> <!--&lt;!&ndash; 前置脚本 &ndash;&gt;-->
<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA" <!--<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA"-->
:jsr223-processor="row"/> <!--:jsr223-processor="row"/>-->
<!--后置脚本--> <!--&lt;!&ndash;后置脚本&ndash;&gt;-->
<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3" <!--<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3"-->
:jsr223-processor="row"/> <!--:jsr223-processor="row"/>-->
<!--断言规则--> <!--&lt;!&ndash;断言规则&ndash;&gt;-->
<ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/> <!--<ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>-->
<!--提取规则--> <!--&lt;!&ndash;提取规则&ndash;&gt;-->
<ms-api-extract :is-read-only="isReadOnly" @copyRow="copyRow" @remove="remove" v-if="row.type==='Extract'" :extract="row"/> <!--<ms-api-extract :is-read-only="isReadOnly" @copyRow="copyRow" @remove="remove" v-if="row.type==='Extract'" :extract="row"/>-->
</div> <!--</div>-->
</el-col> </el-col>
<el-col :span="3" class="ms-left-cell"> <!--<el-col :span="3" class="ms-left-cell">-->
<el-button class="ms-left-buttion" size="small" style="color: #B8741A;background-color: #F9F1EA" @click="addPre">+{{$t('api_test.definition.request.pre_script')}}</el-button> <!--<el-button class="ms-left-buttion" size="small" style="color: #B8741A;background-color: #F9F1EA" @click="addPre">+{{$t('api_test.definition.request.pre_script')}}</el-button>-->
<br/> <!--<br/>-->
<el-button class="ms-left-buttion" size="small" style="color: #783887;background-color: #F2ECF3" @click="addPost">+{{$t('api_test.definition.request.post_script')}}</el-button> <!--<el-button class="ms-left-buttion" size="small" style="color: #783887;background-color: #F2ECF3" @click="addPost">+{{$t('api_test.definition.request.post_script')}}</el-button>-->
<br/> <!--<br/>-->
<el-button class="ms-left-buttion" size="small" style="color: #A30014;background-color: #F7E6E9" @click="addAssertions">+{{$t('api_test.definition.request.assertions_rule')}}</el-button> <!--<el-button class="ms-left-buttion" size="small" style="color: #A30014;background-color: #F7E6E9" @click="addAssertions">+{{$t('api_test.definition.request.assertions_rule')}}</el-button>-->
<br/> <!--<br/>-->
<el-button class="ms-left-buttion" size="small" style="color: #015478;background-color: #E6EEF2" @click="addExtract">+{{$t('api_test.definition.request.extract_param')}}</el-button> <!--<el-button class="ms-left-buttion" size="small" style="color: #015478;background-color: #E6EEF2" @click="addExtract">+{{$t('api_test.definition.request.extract_param')}}</el-button>-->
</el-col> <!--</el-col>-->
</el-row> </el-row>
</div> </div>
</template> </template>

@ -1 +1 @@
Subproject commit aaeb324621dc3197c1bcbd3920600c0963fdea08 Subproject commit 29a8fc09602fde5708af06582ac972d98eb69836

View File

@ -542,6 +542,7 @@ export default {
create_info: 'Create', create_info: 'Create',
update_info: 'Update', update_info: 'Update',
batch_edit: "Batch edit", batch_edit: "Batch edit",
path_valid_info: "The request address cannot contain spaces",
} }
}, },
automation: { automation: {

View File

@ -541,6 +541,7 @@ export default {
create_info: '创建', create_info: '创建',
update_info: '更新', update_info: '更新',
batch_edit: "批量编辑", batch_edit: "批量编辑",
path_valid_info: "请求地址不能包含空格",
} }
}, },
automation: { automation: {

View File

@ -541,6 +541,7 @@ export default {
create_info: '創建', create_info: '創建',
update_info: '更新', update_info: '更新',
batch_edit: "批量編輯", batch_edit: "批量編輯",
path_valid_info: "請求地址不能包含空格",
} }
}, },
automation: { automation: {