Skip to content

Commit 086320a

Browse files
committed
Add support for $oneOf composition and inheritance
1 parent 65f794d commit 086320a

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

models/OpenAPI/Parser.cfc

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,27 +173,33 @@ component name="OpenAPIParser" accessors="true" {
173173
}
174174
} else if( isStruct( DocItem ) ) {
175175

176-
// handle top-level extension
177-
if(
178-
structKeyExists( DocItem, "$allOf" ) &&
179-
isArray( DocItem[ "$allOf" ] )
180-
) {
181-
return extendObject( DocItem[ "$allOf" ] );
182-
}
176+
var compositionKeys = [ "$allOf", "$oneOf" ];
183177

184-
for( var key in DocItem){
178+
for( var composition in compositionKeys ){
185179

186-
if (
187-
isStruct( DocItem[ key ] ) &&
188-
structKeyExists( DocItem[ key ], "$allOf" ) &&
189-
isArray( DocItem[ key ][ "$allOf" ] )
190-
) {
191-
DocItem[ key ] = parseDocumentReferences( extendObject( DocItem[ key ][ "$allOf" ] ) );
192-
} else if( isStruct( DocItem[ key ] ) || isArray( DocItem[ key ] ) ){
193-
DocItem[ key ] = parseDocumentInheritance( parseDocumentReferences( DocItem[ key ] ) );
180+
// handle top-level extension
181+
if(
182+
structKeyExists( DocItem, composition ) &&
183+
isArray( DocItem[ composition ] )
184+
) {
185+
return extendObject( DocItem[ composition ] );
194186
}
195187

188+
for( var key in DocItem){
189+
190+
if (
191+
isStruct( DocItem[ key ] ) &&
192+
structKeyExists( DocItem[ key ], composition ) &&
193+
isArray( DocItem[ key ][ composition ] )
194+
) {
195+
DocItem[ key ] = parseDocumentReferences( extendObject( DocItem[ key ][ composition ] ) );
196+
} else if( isStruct( DocItem[ key ] ) || isArray( DocItem[ key ] ) ){
197+
DocItem[ key ] = parseDocumentInheritance( parseDocumentReferences( DocItem[ key ] ) );
198+
}
199+
200+
}
196201
}
202+
197203
}
198204

199205
return DocItem;

0 commit comments

Comments
 (0)