File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,16 @@ function inverseDictionary(map: Dictionary<string>): Dictionary<string> {
1313}
1414
1515export function findOneOfParentDiscriminator ( openApi : OpenApi , parent ?: Model ) : OpenApiDiscriminator | undefined {
16- if ( openApi . components ) {
16+ if ( openApi . components && parent ) {
1717 for ( const definitionName in openApi . components . schemas ) {
1818 if ( openApi . components . schemas . hasOwnProperty ( definitionName ) ) {
1919 const schema = openApi . components . schemas [ definitionName ] ;
20- if ( parent && schema . oneOf ?. length && schema . discriminator ) {
21- const isPartOf =
22- schema . oneOf
23- . map ( definition => definition . $ref && stripNamespace ( definition . $ref ) === parent . name )
24- . filter ( Boolean ) . length > 0 ;
25- if ( isPartOf ) {
26- return schema . discriminator ;
27- }
20+ if (
21+ schema . discriminator &&
22+ schema . oneOf ?. length &&
23+ schema . oneOf . some ( definition => definition . $ref && stripNamespace ( definition . $ref ) == parent . name )
24+ ) {
25+ return schema . discriminator ;
2826 }
2927 }
3028 }
You can’t perform that action at this time.
0 commit comments