From 0b06de4232d963227b5b5bfca349a6810f72fe69 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 15 Dec 2022 19:44:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DjsonSchema=E5=8F=82=E6=95=B0=E4=B8=BAnull?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020859 --user=宋天阳 【接口测试】接口json-schema中如果有参数a,关闭json-schema,编辑json字符串把参数a改成null,再开启json-schema,a的值没变 https://www.tapd.cn/55049933/s/1316060 --- .../ext/ExtApiScenarioReferenceIdMapper.xml | 3 --- .../definition/ApiDefinitionService.java | 20 ++----------------- .../json-schema/schema/editor/type/null.js | 11 ++++++++++ .../json-schema/schema/editor/type/type.js | 3 ++- .../definition/components/body/ApiBody.vue | 8 ++++++++ .../frontend/src/business/home/ApiHome.vue | 3 ++- 6 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 api-test/frontend/src/business/commons/json-schema/schema/editor/type/null.js diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml index 0e638fd60c..0465bf64ea 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml @@ -11,9 +11,6 @@ AND version_id = #{versionId} - - AND latest = 1 - ) AND reference_id IS NOT NULL diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index 00cf50af03..06a90ef2d9 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -170,7 +170,6 @@ public class ApiDefinitionService { private static final String SCHEDULE = "schedule"; - public List list(ApiDefinitionRequest request) { request = this.initRequest(request, true, true); List resList = extApiDefinitionMapper.list(request); @@ -354,8 +353,8 @@ public class ApiDefinitionService { definitionList = this.selectEffectiveIdByProjectId(request.getProjectId(), versionId); } if (CollectionUtils.isNotEmpty(definitionList)) { - //如果查询条件中有未覆盖/已覆盖, 则需要解析出没有用例的接口中,有多少是符合场景覆盖规律的。然后将这些接口的id作为查询参数 - Map> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(request.getProjectId(), versionId); + //如果查询条件中有未覆盖/已覆盖, 则需要解析出没有用例的接口中,有多少是符合场景覆盖规律的。然后将这些接口的id作为查询参数. 这里不根据版本筛选覆盖的url。 + Map> scenarioUrlList = apiAutomationService.selectScenarioUseUrlByProjectId(request.getProjectId(), null); List apiIdInScenario = apiAutomationService.getApiIdInScenario(request.getProjectId(), scenarioUrlList, definitionList); if (CollectionUtils.isNotEmpty(apiIdInScenario)) { request.setCoverageIds(apiIdInScenario); @@ -935,21 +934,6 @@ public class ApiDefinitionService { } - - - - - - - - - - - - - - - /** * 获取存储执行结果报告 * diff --git a/api-test/frontend/src/business/commons/json-schema/schema/editor/type/null.js b/api-test/frontend/src/business/commons/json-schema/schema/editor/type/null.js new file mode 100644 index 0000000000..25e3efc730 --- /dev/null +++ b/api-test/frontend/src/business/commons/json-schema/schema/editor/type/null.js @@ -0,0 +1,11 @@ +const value = { + description: null, +}; +const attr = { + description: { + name: '描述', + type: 'string', + }, +}; +const wrapper = { value, attr }; +export default wrapper; diff --git a/api-test/frontend/src/business/commons/json-schema/schema/editor/type/type.js b/api-test/frontend/src/business/commons/json-schema/schema/editor/type/type.js index 4530678a50..201514ad1f 100644 --- a/api-test/frontend/src/business/commons/json-schema/schema/editor/type/type.js +++ b/api-test/frontend/src/business/commons/json-schema/schema/editor/type/type.js @@ -4,6 +4,7 @@ import _array from './array'; import _boolean from './boolean'; import _integer from './integer'; import _number from './number'; +import _null from './null'; const TYPE_NAME = ['string', 'number', 'integer', 'object', 'array', 'boolean', 'null']; @@ -14,7 +15,7 @@ const TYPE = { boolean: _boolean, integer: _integer, number: _number, - null: { description: null }, + null: _null, }; export { TYPE, TYPE_NAME }; diff --git a/api-test/frontend/src/business/definition/components/body/ApiBody.vue b/api-test/frontend/src/business/definition/components/body/ApiBody.vue index 516ad1c1d3..3d9affdebb 100644 --- a/api-test/frontend/src/business/definition/components/body/ApiBody.vue +++ b/api-test/frontend/src/business/definition/components/body/ApiBody.vue @@ -212,6 +212,14 @@ export default { this.assignKey(to, from, key); } } + //判断null + if (to.type && from.type) { + to.type = from.type; + if (from.type === 'null') { + this.assign(Object(to.mock), { mock: '' }); + } + } + let property = ['description', 'maxLength', 'minLength', 'pattern', 'format', 'enum', 'default']; // 清除多出部分属性 for (let key in to) { diff --git a/api-test/frontend/src/business/home/ApiHome.vue b/api-test/frontend/src/business/home/ApiHome.vue index b1bde17ae1..d68c3deb07 100644 --- a/api-test/frontend/src/business/home/ApiHome.vue +++ b/api-test/frontend/src/business/home/ApiHome.vue @@ -10,7 +10,7 @@ :placeholder="$t('home.dashboard.public.default_version')" size="small" style="height: 100%"> - + @@ -233,6 +233,7 @@ export default { .api-home-layout :deep(.dashboard-title) { font-size: 18px; font-weight: 500; + color: #1f2329; } .api-home-layout :deep(.common-amount) {