From ddbf6b13418dfac91969eb4cb11fe3384febb405 Mon Sep 17 00:00:00 2001 From: Konrad Jamrozik Date: Thu, 1 Feb 2024 15:37:57 -0800 Subject: [PATCH] Gracefully handle lack of section.value["x-ms-enum"].name in UniqueXmsEnumName. (#657) --- ...ode_to_linter_command_2024-01-30-20-53.json | 10 ---------- ...ypeObjectNoDefinition_2024-01-22-23-22.json | 10 ---------- ...erNotUsingCommonTypes_2024-01-24-18-56.json | 10 ---------- ...-20-53.json => vbump_2024-02-01-23-09.json} | 4 ++-- ...ode_to_linter_command_2024-01-30-20-53.json | 10 ---------- packages/rulesets/CHANGELOG.json | 18 ++++++++++++++++++ packages/rulesets/CHANGELOG.md | 11 ++++++++++- packages/rulesets/package.json | 2 +- .../native/legacyRules/UniqueXmsEnumName.ts | 2 +- 9 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 common/changes/@microsoft.azure/openapi-validator-core/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json delete mode 100644 common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-FPSPropertiesTypeObjectNoDefinition_2024-01-22-23-22.json delete mode 100644 common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-fps-ParameterNotUsingCommonTypes_2024-01-24-18-56.json rename common/changes/@microsoft.azure/openapi-validator-rulesets/{akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json => vbump_2024-02-01-23-09.json} (71%) delete mode 100644 common/changes/@microsoft.azure/openapi-validator/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json diff --git a/common/changes/@microsoft.azure/openapi-validator-core/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json b/common/changes/@microsoft.azure/openapi-validator-core/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json deleted file mode 100644 index 4932b72c2..000000000 --- a/common/changes/@microsoft.azure/openapi-validator-core/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@microsoft.azure/openapi-validator-core", - "comment": "Upgrade version to 1.0.4", - "type": "patch" - } - ], - "packageName": "@microsoft.azure/openapi-validator-core" -} \ No newline at end of file diff --git a/common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-FPSPropertiesTypeObjectNoDefinition_2024-01-22-23-22.json b/common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-FPSPropertiesTypeObjectNoDefinition_2024-01-22-23-22.json deleted file mode 100644 index 4bff62e6a..000000000 --- a/common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-FPSPropertiesTypeObjectNoDefinition_2024-01-22-23-22.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@microsoft.azure/openapi-validator-rulesets", - "comment": "Fix an issue where PropertiesTypeObjectNoDefinition must verify the existence of the allOf property in the definition object.", - "type": "patch" - } - ], - "packageName": "@microsoft.azure/openapi-validator-rulesets" -} \ No newline at end of file diff --git a/common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-fps-ParameterNotUsingCommonTypes_2024-01-24-18-56.json b/common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-fps-ParameterNotUsingCommonTypes_2024-01-24-18-56.json deleted file mode 100644 index 816b72c10..000000000 --- a/common/changes/@microsoft.azure/openapi-validator-rulesets/tejaswis-fps-ParameterNotUsingCommonTypes_2024-01-24-18-56.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@microsoft.azure/openapi-validator-rulesets", - "comment": "Fix a false alarm with the ParameterNotUsingCommonTypes rule that resulted in errors being flagged even when common-types were being referenced correctly.", - "type": "patch" - } - ], - "packageName": "@microsoft.azure/openapi-validator-rulesets" -} \ No newline at end of file diff --git a/common/changes/@microsoft.azure/openapi-validator-rulesets/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json b/common/changes/@microsoft.azure/openapi-validator-rulesets/vbump_2024-02-01-23-09.json similarity index 71% rename from common/changes/@microsoft.azure/openapi-validator-rulesets/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json rename to common/changes/@microsoft.azure/openapi-validator-rulesets/vbump_2024-02-01-23-09.json index bc3e47416..f64913372 100644 --- a/common/changes/@microsoft.azure/openapi-validator-rulesets/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json +++ b/common/changes/@microsoft.azure/openapi-validator-rulesets/vbump_2024-02-01-23-09.json @@ -2,8 +2,8 @@ "changes": [ { "packageName": "@microsoft.azure/openapi-validator-rulesets", - "comment": "Upgrade version to 1.3.3", - "type": "patch" + "comment": "rush version --bump", + "type": "none" } ], "packageName": "@microsoft.azure/openapi-validator-rulesets" diff --git a/common/changes/@microsoft.azure/openapi-validator/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json b/common/changes/@microsoft.azure/openapi-validator/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json deleted file mode 100644 index 5f97f2f9b..000000000 --- a/common/changes/@microsoft.azure/openapi-validator/akhilailla-add_rpc_guideline_code_to_linter_command_2024-01-30-20-53.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "changes": [ - { - "packageName": "@microsoft.azure/openapi-validator", - "comment": "Upgrade version to 2.1.7", - "type": "patch" - } - ], - "packageName": "@microsoft.azure/openapi-validator" -} \ No newline at end of file diff --git a/packages/rulesets/CHANGELOG.json b/packages/rulesets/CHANGELOG.json index 8bccba101..2763d2ac2 100644 --- a/packages/rulesets/CHANGELOG.json +++ b/packages/rulesets/CHANGELOG.json @@ -1,6 +1,18 @@ { "name": "@microsoft.azure/openapi-validator-rulesets", "entries": [ + { + "version": "1.3.4", + "tag": "@microsoft.azure/openapi-validator-rulesets_v1.3.4", + "date": "Thu, 01 Feb 2024 23:08:29 GMT", + "comments": { + "patch": [ + { + "comment": "Gracefully handle lack of section.value[\"x-ms-enum\"].name in UniqueXmsEnumName. Solves https://github.com/Azure/azure-openapi-validator/issues/654" + } + ] + } + }, { "version": "1.3.3", "tag": "@microsoft.azure/openapi-validator-rulesets_v1.3.3", @@ -24,6 +36,12 @@ }, { "comment": "Add RPC code to ProvisioningStateMustBeReadOnly and fix documentation" + }, + { + "comment": "Fix a false alarm with the ParameterNotUsingCommonTypes rule that resulted in errors being flagged even when common-types were being referenced correctly." + }, + { + "comment": "Fix an issue where PropertiesTypeObjectNoDefinition must verify the existence of the allOf property in the definition object." } ] } diff --git a/packages/rulesets/CHANGELOG.md b/packages/rulesets/CHANGELOG.md index 456b60688..3a98828ce 100644 --- a/packages/rulesets/CHANGELOG.md +++ b/packages/rulesets/CHANGELOG.md @@ -1,6 +1,13 @@ # Change Log - @microsoft.azure/openapi-validator-rulesets -This log was last generated on Tue, 30 Jan 2024 18:28:15 GMT and should not be manually modified. +This log was last generated on Thu, 01 Feb 2024 23:08:29 GMT and should not be manually modified. + +## 1.3.4 +Thu, 01 Feb 2024 23:08:29 GMT + +### Patches + +- Gracefully handle lack of section.value["x-ms-enum"].name in UniqueXmsEnumName. Solves https://github.com/Azure/azure-openapi-validator/issues/654 ## 1.3.3 Tue, 30 Jan 2024 18:28:15 GMT @@ -13,6 +20,8 @@ Tue, 30 Jan 2024 18:28:15 GMT - Update latestVersionOfCommonTypesMustBeUsed rule to check for latest version(V5) of all common types - Upgrade version to 1.3.2 - Add RPC code to ProvisioningStateMustBeReadOnly and fix documentation +- Fix a false alarm with the ParameterNotUsingCommonTypes rule that resulted in errors being flagged even when common-types were being referenced correctly. +- Fix an issue where PropertiesTypeObjectNoDefinition must verify the existence of the allOf property in the definition object. ## 1.3.2 Tue, 19 Dec 2023 21:25:29 GMT diff --git a/packages/rulesets/package.json b/packages/rulesets/package.json index 6b35a81a4..731621523 100644 --- a/packages/rulesets/package.json +++ b/packages/rulesets/package.json @@ -1,6 +1,6 @@ { "name": "@microsoft.azure/openapi-validator-rulesets", - "version": "1.3.3", + "version": "1.3.4", "description": "Azure OpenAPI Validator", "main": "dist/index.js", "scripts": { diff --git a/packages/rulesets/src/native/legacyRules/UniqueXmsEnumName.ts b/packages/rulesets/src/native/legacyRules/UniqueXmsEnumName.ts index deb930f40..056788f47 100644 --- a/packages/rulesets/src/native/legacyRules/UniqueXmsEnumName.ts +++ b/packages/rulesets/src/native/legacyRules/UniqueXmsEnumName.ts @@ -20,7 +20,7 @@ rules.push({ if (node) { const enumMap = new Map() for (const section of nodes(node, "$..*[?(@property === 'enum')]^")) { - if (section.value["x-ms-enum"] && isValidEnum(section.value)) { + if (isValidEnum(section.value) && section.value["x-ms-enum"] && section.value["x-ms-enum"].name) { const enumName = section.value["x-ms-enum"].name.toLowerCase() if (enumMap.has(enumName)) { const curEnum = section.value.enum