@@ -76,7 +76,10 @@ component name="OpenAPIParser" accessors="true" {
7676 break ;
7777
7878 default :
79- throw ( type = " SwaggerSDK.ParserException" , message = " SwaggerSDK does not support schema using the .#lcase (getSchemaType ()) # file extension." );
79+ throw (
80+ type = " SwaggerSDK.ParserException" ,
81+ message = " SwaggerSDK does not support schema using the .#lcase (getSchemaType ()) # file extension."
82+ );
8083 }
8184
8285 return parse ( documentContent , XPath );
@@ -96,7 +99,9 @@ component name="OpenAPIParser" accessors="true" {
9699 var Document = getDocumentObject ().getDocument ();
97100
98101 for ( var key in Document ){
99- Document [ key ] = parseDocumentReferences ( Document [ key ] );
102+ if ( isSimpleValue ( key ) ){
103+ Document [ key ] = parseDocumentReferences ( Document [ key ] );
104+ }
100105 }
101106
102107 return this ;
@@ -143,9 +148,13 @@ component name="OpenAPIParser" accessors="true" {
143148 &&
144149 structKeyExists ( DocItem [ key ], " $ref" )
145150 ) {
151+
146152 DocItem [ key ] = fetchDocumentReference ( DocItem [ key ][ " $ref" ] );
153+
147154 } else if ( isStruct ( DocItem [ key ] ) || isArray ( DocItem [ key ] ) ){
155+
148156 DocItem [ key ] = parseDocumentReferences ( DocItem [ key ] );
157+
149158 }
150159
151160 }
@@ -193,33 +202,44 @@ component name="OpenAPIParser" accessors="true" {
193202
194203 var ReferenceDocument = {};
195204
196- // Files receive a parser reference
197- if ( left ( FilePath , 4 ) == ' http' ){
205+ try {
198206
199- var ReferenceDocument = Wirebox .getInstance ( " OpenAPIParser@SwaggerSDK" ).init ( $ref );
207+ // Files receive a parser reference
208+ if ( left ( FilePath , 4 ) == ' http' ){
209+
210+ var ReferenceDocument = Wirebox .getInstance ( " OpenAPIParser@SwaggerSDK" ).init ( $ref );
200211
201- } else if ( len ( FilePath ) && fileExists ( getDirectoryFromPath ( getBaseDocumentPath () ) & FilePath )){
212+ } else if ( len ( FilePath ) && fileExists ( getDirectoryFromPath ( getBaseDocumentPath () ) & FilePath )){
202213
203- var ReferenceDocument = Wirebox .getInstance ( " OpenAPIParser@SwaggerSDK" ).init ( getDirectoryFromPath ( getBaseDocumentPath () ) & $ref );
204-
205- } else if ( len ( FilePath ) && fileExists ( expandPath ( FilePath ) ) ) {
214+ var ReferenceDocument = Wirebox .getInstance ( " OpenAPIParser@SwaggerSDK" ).init ( getDirectoryFromPath ( getBaseDocumentPath () ) & $ref );
215+
216+ } else if ( len ( FilePath ) && fileExists ( expandPath ( FilePath ) ) ) {
206217
207- var ReferenceDocument = Wirebox .getInstance ( " OpenAPIParser@SwaggerSDK" ).init ( expandPath ( FilePath ) & ( ! isNull ( xPath ) ? " ## " & xPath : " " ) );
218+ var ReferenceDocument = Wirebox .getInstance ( " OpenAPIParser@SwaggerSDK" ).init ( expandPath ( FilePath ) & ( ! isNull ( xPath ) ? " ## " & xPath : " " ) );
208219
209- } else if ( len ( FilePath ) && ! fileExists ( getDirectoryFromPath ( getBaseDocumentPath () ) & FilePath )) {
220+ } else if ( len ( FilePath ) && ! fileExists ( getDirectoryFromPath ( getBaseDocumentPath () ) & FilePath )) {
210221
211- throw ( type = " SwaggerSDK.ParserException" , message = " File #( getDirectoryFromPath ( getBaseDocumentPath () ) & FilePath ) # does not exist" );
222+ throw ( type = " SwaggerSDK.ParserException" , message = " File #( getDirectoryFromPath ( getBaseDocumentPath () ) & FilePath ) # does not exist" );
212223
213- } else if ( ! isNull ( XPath ) && len ( XPath ) ) {
224+ } else if ( ! isNull ( XPath ) && len ( XPath ) ) {
214225
215- var ReferenceDocument = getInternalXPath ( XPath );
226+ var ReferenceDocument = getInternalXPath ( XPath );
216227
217- } else {
228+ } else {
218229
219- throw ( type = " SwaggerSDK.ParserException" , message = " The $ref #$ref # could not be resolved as either an internal or external reference" );
230+ throw ( type = " SwaggerSDK.ParserException" , message = " The $ref #$ref # could not be resolved as either an internal or external reference" );
220231
221- }
232+ }
233+
234+ } catch ( any e ){
222235
236+ throw (
237+ type = " CBSwagger.InvalidReferenceDocumentException" ,
238+ message = " The $ref file pointer of #$ref # could not be loaded and parsed as a valid object. If your $ref file content is an array, please nest the array within an object as a named key."
239+ );
240+
241+ }
242+
223243 return ReferenceDocument ;
224244 }
225245
0 commit comments