Skip to content

Commit 5ede6d1

Browse files
committed
Resolves Issue #19 - Prevents a stack overflow and maintains a $ref when it cannot be parsed from the current document
1 parent fce4398 commit 5ede6d1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

models/OpenAPI/Document.cfc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,19 @@ component name="OpenAPIDocument" accessors="true" {
117117
* Helper function to locate deeply nested document items
118118
*
119119
* @param key the key to locate
120-
* @return any the value of the key or null if the key is not found
120+
* @return any the value of the key or a `$ref` object if the key is not found
121121
* @usage locate('key.subkey.subsubkey.waydowndeepsubkey')
122122
**/
123123
any function locate( string key ){
124124
var rootDocument = this.getRootDocument();
125125

126126
if( structKeyExists( rootDocument, arguments.key ) ){
127127
return rootDocument[ arguments.key ];
128-
} else {
129-
if( isDefined( 'rootDocument.#arguments.key#' ) ){
128+
} else if( isDefined( 'rootDocument.#arguments.key#' ) ){
130129
return evaluate( 'rootDocument.#arguments.key#' );
131-
}
130+
} else {
131+
return { "$ref" : "##/#arrayToList( listToArray( arguments.key, "." ), "/" )#"};
132132
}
133-
134-
return getDocument();
135133
}
136134

137135
/********************************************************************************/

0 commit comments

Comments
 (0)