From 26bfaece239732a8a9066998987e65548bbc0a9d Mon Sep 17 00:00:00 2001 From: wtrocki Date: Thu, 6 Mar 2025 10:56:32 +0100 Subject: [PATCH 1/4] task: minor fix for collection utils --- .../rulesets/functions/utils/collectionUtils.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js index 653c632fc6..71c81e822f 100644 --- a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js +++ b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js @@ -4,15 +4,15 @@ import { EXCEPTION_EXTENSION } from './exceptions.js'; /** * Collects a violation entry and returns formatted error data. * - * @param {Array} path - The JSON path for the object where the rule violation occurred. + * @param {Array} jsonPath - The JSON path for the object where the rule violation occurred. Example: 'paths./pets.get]) * @param {string} ruleName - The name of the rule that was violated. * @param {string|Array} errorData - The error information. Can be either a string message or an array of error objects. * @returns {Array} An array of error objects. Each object has a 'message' property. * @throws {Error} Throws an error if errorData is neither a string nor an array. * */ -export function collectAndReturnViolation(path, ruleName, errorData) { - collector.add(EntryType.VIOLATION, path, ruleName); +export function collectAndReturnViolation(jsonPath, ruleName, errorData) { + collector.add(EntryType.VIOLATION, jsonPath, ruleName); if (typeof errorData === 'string') { return [{ message: errorData }]; @@ -29,8 +29,8 @@ export function collectAndReturnViolation(path, ruleName, errorData) { * @param {Array} path - The JSON path for the object where the rule adoption occurred. * @param {string} ruleName - The name of the rule that was adopted. */ -export function collectAdoption(path, ruleName) { - collector.add(EntryType.ADOPTION, path, ruleName); +export function collectAdoption(jsonPath, ruleName) { + collector.add(EntryType.ADOPTION, jsonPath, ruleName); } /** @@ -40,9 +40,9 @@ export function collectAdoption(path, ruleName) { * @param {Array} path - The JSON path for the object where the rule exception occurred. * @param {string} ruleName - The name of the rule that the exception is defined for. */ -export function collectException(object, ruleName, path) { +export function collectException(object, ruleName, jsonPath) { let exceptionReason = object[EXCEPTION_EXTENSION][ruleName]; if (exceptionReason) { - collector.add(EntryType.EXCEPTION, path, ruleName, exceptionReason); + collector.add(EntryType.EXCEPTION, jsonPath, ruleName, exceptionReason); } } From 6f6bc0b90cc33b1a18846b442d94205169d026f9 Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Thu, 6 Mar 2025 11:01:28 +0100 Subject: [PATCH 2/4] Update jsonPath parameter description in JSDoc --- tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js index 71c81e822f..2d07497719 100644 --- a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js +++ b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js @@ -4,7 +4,7 @@ import { EXCEPTION_EXTENSION } from './exceptions.js'; /** * Collects a violation entry and returns formatted error data. * - * @param {Array} jsonPath - The JSON path for the object where the rule violation occurred. Example: 'paths./pets.get]) + * @param {Array} jsonPath - The JSON path array for the object where the rule violation occurred. Example: ["paths","./pets","get"] * @param {string} ruleName - The name of the rule that was violated. * @param {string|Array} errorData - The error information. Can be either a string message or an array of error objects. * @returns {Array} An array of error objects. Each object has a 'message' property. From a3c1bb9eae561779365b569ed4e523062e247eba Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Thu, 6 Mar 2025 11:14:51 +0100 Subject: [PATCH 3/4] Rename parameter 'path' to 'jsonPath' --- tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js index 2d07497719..288f6a213c 100644 --- a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js +++ b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js @@ -26,7 +26,7 @@ export function collectAndReturnViolation(jsonPath, ruleName, errorData) { /** * Collects an adoption entry. * - * @param {Array} path - The JSON path for the object where the rule adoption occurred. + * @param {Array} jsonPath - The JSON path array for the object where the rule violation occurred. Example: ["paths","./pets","get"] * @param {string} ruleName - The name of the rule that was adopted. */ export function collectAdoption(jsonPath, ruleName) { From 8766e6a386304366049598cc493cb617883bd335 Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Thu, 6 Mar 2025 11:21:02 +0100 Subject: [PATCH 4/4] Rename parameter 'path' to 'jsonPath' --- tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js index 288f6a213c..ab8c931bee 100644 --- a/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js +++ b/tools/spectral/ipa/rulesets/functions/utils/collectionUtils.js @@ -37,7 +37,7 @@ export function collectAdoption(jsonPath, ruleName) { * Collects an exception entry. * * @param object the object to evaluate - * @param {Array} path - The JSON path for the object where the rule exception occurred. + * @param {Array} jsonPath - The JSON path array for the object where the rule violation occurred. Example: ["paths","./pets","get"] * @param {string} ruleName - The name of the rule that the exception is defined for. */ export function collectException(object, ruleName, jsonPath) {