Skip to content

Commit 5e4caa9

Browse files
changes in compareSchemas
1 parent 29c75ff commit 5e4caa9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tools/spectral/ipa/rulesets/functions/utils/schemaUtils.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,27 @@ export function compareSchemas(postSchema, getSchema) {
5757
continue;
5858
}
5959

60+
if(postProps[prop].type !== getProps[prop].type) {
61+
inconsistentFields.push(prop);
62+
continue;
63+
}
64+
6065
// For objects, compare nested properties
61-
if (postProps[prop].type === 'object' && getProps[prop].type === 'object') {
66+
if (postProps[prop].type === 'object') {
6267
const nestedInconsistencies = compareSchemas(postProps[prop], getProps[prop]);
6368
if (nestedInconsistencies.length > 0) {
6469
// Prefix nested fields with their parent name
6570
inconsistentFields.push(...nestedInconsistencies.map((field) => `${prop}.${field}`));
6671
}
6772
}
73+
74+
if(postProps[prop].type === 'array') {
75+
const nestedInconsistencies = compareSchemas(postProps[prop].items, getProps[prop].items);
76+
if (nestedInconsistencies.length > 0) {
77+
// Prefix nested fields with their parent name
78+
inconsistentFields.push(...nestedInconsistencies.map((field) => `${prop}.${field}`));
79+
}
80+
}
6881
}
6982

7083
return inconsistentFields;

0 commit comments

Comments
 (0)