File tree 1 file changed +7
-9
lines changed
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> {
13
13
}
14
14
15
15
export function findOneOfParentDiscriminator ( openApi : OpenApi , parent ?: Model ) : OpenApiDiscriminator | undefined {
16
- if ( openApi . components ) {
16
+ if ( openApi . components && parent ) {
17
17
for ( const definitionName in openApi . components . schemas ) {
18
18
if ( openApi . components . schemas . hasOwnProperty ( definitionName ) ) {
19
19
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 ;
28
26
}
29
27
}
30
28
}
You can’t perform that action at this time.
0 commit comments