@@ -75,11 +75,7 @@ export class SchemaModel {
75
75
this . init ( parser , isChild ) ;
76
76
77
77
parser . exitRef ( schemaOrRef ) ;
78
-
79
- for ( const parent$ref of this . schema . parentRefs || [ ] ) {
80
- // exit all the refs visited during allOf traverse
81
- parser . exitRef ( { $ref : parent$ref } ) ;
82
- }
78
+ parser . exitParents ( this . schema ) ;
83
79
84
80
if ( options . showExtensions ) {
85
81
this . extensions = extractExtensions ( this . schema , options . showExtensions ) ;
@@ -164,20 +160,28 @@ export class SchemaModel {
164
160
}
165
161
166
162
private initOneOf ( oneOf : OpenAPISchema [ ] , parser : OpenAPIParser ) {
167
- this . oneOf = oneOf ! . map (
168
- ( variant , idx ) =>
169
- new SchemaModel (
170
- parser ,
171
- // merge base schema into each of oneOf's subschemas
172
- {
173
- // variant may already have allOf so merge it to not get overwritten
174
- ...parser . mergeAllOf ( variant , this . pointer + '/oneOf/' + idx ) ,
175
- allOf : [ { ...this . schema , oneOf : undefined , anyOf : undefined } ] ,
176
- } as OpenAPISchema ,
177
- this . pointer + '/oneOf/' + idx ,
178
- this . options ,
179
- ) ,
180
- ) ;
163
+ this . oneOf = oneOf ! . map ( ( variant , idx ) => {
164
+ const merged = parser . mergeAllOf ( variant , this . pointer + '/oneOf/' + idx ) ;
165
+
166
+ const schema = new SchemaModel (
167
+ parser ,
168
+ // merge base schema into each of oneOf's subschemas
169
+ {
170
+ // variant may already have allOf so merge it to not get overwritten
171
+ ...merged ,
172
+ allOf : [ { ...this . schema , oneOf : undefined , anyOf : undefined } ] ,
173
+ } as OpenAPISchema ,
174
+ this . pointer + '/oneOf/' + idx ,
175
+ this . options ,
176
+ ) ;
177
+
178
+ // each oneOf should be independent so exiting all the parent refs
179
+ // otherwise it will cause false-positive recursive detection
180
+ parser . exitParents ( merged ) ;
181
+
182
+ return schema ;
183
+ } ) ;
184
+
181
185
this . displayType = this . oneOf
182
186
. map ( schema => {
183
187
let name =
0 commit comments