@@ -143,22 +143,11 @@ component name="OpenAPIParser" accessors="true" {
143143 }
144144
145145 for ( var key in DocItem ){
146-
147146 if ( isNull ( docItem [ key ] ) ){
148- DocItem [ key ] = nullValue ();
149147 continue ;
150- }
151-
152- // If `DocItem[ key ]` is an instance of Parser, we need to flattin it to a CFML struct
153- if (
154- isStruct ( DocItem [ key ] ) &&
155- findNoCase ( " Parser" , getMetaData ( DocItem [ key ] ).name )
156- ) {
157- DocItem [ key ] = DocItem [ key ].getNormalizedDocument ();
158- }
159-
160- if (
161- isStruct ( DocItem [ key ] ) &&
148+ } else if (
149+ isStruct ( DocItem [ key ] )
150+ &&
162151 structKeyExists ( DocItem [ key ], " $ref" )
163152 ) {
164153
@@ -198,22 +187,32 @@ component name="OpenAPIParser" accessors="true" {
198187 for ( var i = 1 ; i <= arrayLen ( DocItem ); i ++ ){
199188 DocItem [ i ] = parseDocumentInheritance ( DocItem [ i ] );
200189 }
201- } else if ( isStruct ( DocItem ) ) {
190+ } else if ( isStruct ( DocItem ) ) {
202191
203- // handle top-level extension
204- if ( structKeyExists ( DocItem , " $extend" ) ) {
205- return extendObject ( parseDocumentInheritance ( DocItem [ " $extend" ] ) );
206- }
192+ var compositionKeys = [ " $allOf" , " $oneOf" ];
207193
208- for ( var key in DocItem ){
194+ for ( var composition in compositionKeys ){
209195
210- if ( isNull ( docItem [ key ] ) ){
211- DocItem [ key ] = nullValue ();
212- continue ;
196+ // handle top-level extension
197+ if (
198+ structKeyExists ( DocItem , composition ) &&
199+ isArray ( DocItem [ composition ] )
200+ ) {
201+ return extendObject ( DocItem [ composition ] );
213202 }
214- if ( isStruct ( DocItem [ key ] ) || isArray ( DocItem [ key ] ) ){
215- DocItem [ key ] = parseDocumentInheritance ( DocItem [ key ] );
216- }
203+
204+ for ( var key in DocItem ){
205+ if ( isNull ( docItem [ key ] ) ){
206+ continue ;
207+ } else if (
208+ isStruct ( DocItem [ key ] ) &&
209+ structKeyExists ( DocItem [ key ], composition ) &&
210+ isArray ( DocItem [ key ][ composition ] )
211+ ) {
212+ DocItem [ key ] = parseDocumentReferences ( extendObject ( DocItem [ key ][ composition ] ) );
213+ } else if ( isStruct ( DocItem [ key ] ) || isArray ( DocItem [ key ] ) ){
214+ DocItem [ key ] = parseDocumentInheritance ( parseDocumentReferences ( DocItem [ key ] ) );
215+ }
217216
218217 }
219218
@@ -235,6 +234,12 @@ component name="OpenAPIParser" accessors="true" {
235234 var output = {};
236235 objects .each ( function ( item , index ) {
237236 if ( isStruct ( item ) ) {
237+
238+ // If `item` is an instance of Parser, we need to flattin it to a CFML struct
239+ if ( findNoCase ( " Parser" , getMetaData ( item ).name ) ) {
240+ item = item .getNormalizedDocument ();
241+ }
242+
238243 item .each ( function ( key , value ) {
239244
240245 if (
@@ -320,11 +325,10 @@ component name="OpenAPIParser" accessors="true" {
320325 ReferenceDocument = getInternalXPath ( XPath );
321326
322327 } else {
323-
324328 throw ( type = " SwaggerSDK.ParserException" , message = " The $ref #$ref # could not be resolved as either an internal or external reference" );
325-
326329 }
327-
330+ } catch ( SwaggerSDK .ParserException e ){
331+ rethrow ;
328332 } catch ( any e ){
329333
330334 // if this is a known exception or occured via recursion, rethrow the exception so the user knows which JSON file triggered it
0 commit comments