Created
November 10, 2022 21:34
-
-
Save homestar9/1d69b183e4c7e0658067c5b23995aa13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extends schema definitions based on the passed array of schema objects | |
* Note: Ignores CFML objects (non-structs) because sometimes the parser gets passed in here for some reason | |
* | |
* @objects | |
*/ | |
function extendObject( array objects ) { | |
var output = { | |
"type": "object" | |
}; | |
objects.each( function( item, index ) { | |
if ( isStruct( item ) ) { | |
// If item is an instance of Parser, we need to normalize so we get a CFML struct | |
if ( isInstanceOf( item, "Parser" ) ) { | |
item = item.getNormalizedDocument(); | |
} | |
item.each( function( key, value ) { | |
if ( | |
output.keyExists( key ) && | |
isStruct( output[ key ] ) | |
) { | |
output[ key ].append( value, true ); | |
} else { | |
output[ key ] = value | |
} | |
} ); | |
} | |
} ); | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment