File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
tools/spectral/ipa/rulesets/functions/utils Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments