From 46f761f01afe40e69bda84ee7e8bdb2a0350ae93 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Mon, 25 May 2020 17:30:58 +0800 Subject: [PATCH] Fixed nullable value bug (#511) * Fixed nullable value bug Avoid adding nullable value for parameter when its' type isn't string. --- ChangeLog.md | 7 +- lib/util/utils.ts | 2 +- package-lock.json | 2 +- package.json | 2 +- .../examples/AddomainServiceMembers.json | 138 +++++++++--------- test/sourceMapTests.ts | 5 +- 6 files changed, 81 insertions(+), 75 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 0e178af5..ae525976 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,11 @@ # Changelog -## 04/10/2020 0.21.5 +## 05/21/2020 0.21.6 + +- Avoid adding nullable value for parameter when its' type isn't string +- Output exception infomation for semantic validation + +## 04/20/2020 0.21.5 - Output exception information when pretty switch is enabled. diff --git a/lib/util/utils.ts b/lib/util/utils.ts index 16ad6671..54d6b1ff 100644 --- a/lib/util/utils.ts +++ b/lib/util/utils.ts @@ -647,7 +647,7 @@ export function allowNullableParams(parameter: ParameterObject): ParameterObject if (parameter.in && parameter.in === "body" && parameter.schema) { parameter.schema = allowNullableTypes(parameter.schema) } else { - if (parameter.in && parameter.in !== "path") { + if (parameter.in && parameter.in !== "path" && parameter.type === "string") { parameter = allowNullType(parameter, parameter.required) } } diff --git a/package-lock.json b/package-lock.json index 781f6311..895fe3bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "oav", - "version": "0.21.5", + "version": "0.21.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f2ed590f..76365cbf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oav", - "version": "0.21.5", + "version": "0.21.6", "author": { "name": "Microsoft Corporation", "email": "azsdkteam@microsoft.com", diff --git a/test/modelValidation/swaggers/specification/source-map/Microsoft.ADHybridHealthService/stable/2014-01-01/examples/AddomainServiceMembers.json b/test/modelValidation/swaggers/specification/source-map/Microsoft.ADHybridHealthService/stable/2014-01-01/examples/AddomainServiceMembers.json index 84e9a088..190af613 100644 --- a/test/modelValidation/swaggers/specification/source-map/Microsoft.ADHybridHealthService/stable/2014-01-01/examples/AddomainServiceMembers.json +++ b/test/modelValidation/swaggers/specification/source-map/Microsoft.ADHybridHealthService/stable/2014-01-01/examples/AddomainServiceMembers.json @@ -2,7 +2,7 @@ "parameters": { "serviceName": "sampleServiceName", "isGroupbySite": true, - "takeCount": "1", + "takeCount": "string", "nextPartitionKey": " ", "nextRowKey": " ", "api-version": "2014-01-01" @@ -10,80 +10,80 @@ "responses": { "200": { "body": { - "value": [ - { - "domainName": "sampleDomainName", - "siteName": "Default-First-Site-Name", - "addsRoles": [ - "sampleRole" - ], - "gcReachable": true, - "isAdvertising": true, - "pdcReachable": true, - "sysvolState": true, - "dcTypes": [ - "GC" - ], - "lastReboot": "2018-04-28T23:17:00.511864Z", - "lastDisabled": "2018-04-28T23:17:00.511864Z", - "lastUpdated": "2018-04-30T18:00:41.6956022Z", - "activeAlerts": 0, - "resolvedAlerts": 0, - "createdDate": "2018-04-28T23:17:00.511864Z", - "disabled": false, - "dimensions": [ - { - "key": "key1", - "value": "value1" - } - ], - "additionalInformation": "SampleAdditionalInformation", - "tenantId": "00000000-0000-0000-0000-000000000000", - "serviceId": "serviceIdGuid", - "serviceMemberId": "ServiceMemberIdGuid", - "machineId": "machineIdGuid", - "machineName": "sampleMachineName", - "role": "SampleRole", - "status": "Healthy", - "properties": [ - { - "key": "key1", - "value": "value1" - } - ], - "installedQfes": [{ + "value": [ + { + "domainName": "sampleDomainName", + "siteName": "Default-First-Site-Name", + "addsRoles": ["sampleRole"], + "gcReachable": true, + "isAdvertising": true, + "pdcReachable": true, + "sysvolState": true, + "dcTypes": ["GC"], + "lastReboot": "2018-04-28T23:17:00.511864Z", + "lastDisabled": "2018-04-28T23:17:00.511864Z", + "lastUpdated": "2018-04-30T18:00:41.6956022Z", + "activeAlerts": 0, + "resolvedAlerts": 0, + "createdDate": "2018-04-28T23:17:00.511864Z", + "disabled": false, + "dimensions": [ + { + "key": "key1", + "value": "value1" + } + ], + "additionalInformation": "SampleAdditionalInformation", + "tenantId": "00000000-0000-0000-0000-000000000000", + "serviceId": "serviceIdGuid", + "serviceMemberId": "ServiceMemberIdGuid", + "machineId": "machineIdGuid", + "machineName": "sampleMachineName", + "role": "SampleRole", + "status": "Healthy", + "properties": [ + { + "key": "key1", + "value": "value1" + } + ], + "installedQfes": [ + { "kbName": "KB3019978", "link": "SampleLink", "installedDate": "2016-11-06T04:00:00Z" - }], - "recommendedQfes": [{ + } + ], + "recommendedQfes": [ + { "kbName": "KB3019978", "link": "SampleLink", "installedDate": "2016-11-06T04:00:00Z" - }], - "monitoringConfigurationsComputed": [ - { - "key": "key1", - "value": "value1" - } - ], - "monitoringConfigurationsCustomized": [ - { - "key": "key1", - "value": "value1" - } - ], - "osVersion": "osVersion", - "osName": "osName", - "disabledReason": 0, - "serverReportedMonitoringLevel": "Off", - "lastServerReportedMonitoringLevelChange": "2018-04-30T18:00:41.6956022Z" - } - ], - "nextLink": null, - "totalCount": 0, - "continuationToken": null - } + } + ], + "monitoringConfigurationsComputed": [ + { + "key": "key1", + "value": "value1" + } + ], + "monitoringConfigurationsCustomized": [ + { + "key": "key1", + "value": "value1" + } + ], + "osVersion": "osVersion", + "osName": "osName", + "disabledReason": 0, + "serverReportedMonitoringLevel": "Off", + "lastServerReportedMonitoringLevelChange": "2018-04-30T18:00:41.6956022Z" + } + ], + "nextLink": null, + "totalCount": 0, + "continuationToken": null } } + } } diff --git a/test/sourceMapTests.ts b/test/sourceMapTests.ts index 81d8b8d1..09db7027 100644 --- a/test/sourceMapTests.ts +++ b/test/sourceMapTests.ts @@ -16,7 +16,8 @@ describe("sourceMap", () => { assert.strictEqual(result.length, 1) const result0 = result[0] const e = result0.details as any - assert.strictEqual(e.url, file) - assert.deepStrictEqual(e.position, { line: 76, column: 11 }) + assert.strictEqual(e.jsonPath, "$.parameters.takeCount") + assert.strictEqual(e.code, "INVALID_TYPE") + assert.strictEqual(e.message, "Expected type integer but found type string") }) })