@@ -143,11 +143,18 @@ const OpenApi3_0DereferenceVisitor = stampit({
143
143
}
144
144
145
145
const retrievalURI = this . toBaseURI ( toValue ( referencingElement . $ref ) ) ;
146
+ const isInternalReference = url . stripHash ( this . reference . uri ) === retrievalURI ;
147
+ const isExternalReference = ! isInternalReference ;
146
148
149
+ // ignore resolving internal Reference Objects
150
+ if ( ! this . options . resolve . internal && isInternalReference ) {
151
+ // skip traversing this reference element
152
+ return false ;
153
+ }
147
154
// ignore resolving external Reference Objects
148
- if ( ! this . options . resolve . external && url . stripHash ( this . reference . uri ) !== retrievalURI ) {
149
- // skip traversing this reference element but traverse all it's child elements
150
- return undefined ;
155
+ if ( ! this . options . resolve . external && isExternalReference ) {
156
+ // skip traversing this reference element
157
+ return false ;
151
158
}
152
159
153
160
const reference = await this . toReference ( toValue ( referencingElement . $ref ) ) ;
@@ -273,9 +280,16 @@ const OpenApi3_0DereferenceVisitor = stampit({
273
280
}
274
281
275
282
const retrievalURI = this . toBaseURI ( toValue ( referencingElement . $ref ) ) ;
283
+ const isInternalReference = url . stripHash ( this . reference . uri ) === retrievalURI ;
284
+ const isExternalReference = ! isInternalReference ;
276
285
286
+ // ignore resolving internal Path Item Objects
287
+ if ( ! this . options . resolve . internal && isInternalReference ) {
288
+ // skip traversing this Path Item element but traverse all it's child elements
289
+ return undefined ;
290
+ }
277
291
// ignore resolving external Path Item Objects
278
- if ( ! this . options . resolve . external && url . stripHash ( this . reference . uri ) !== retrievalURI ) {
292
+ if ( ! this . options . resolve . external && isExternalReference ) {
279
293
// skip traversing this Path Item element but traverse all it's child elements
280
294
return undefined ;
281
295
}
@@ -406,9 +420,16 @@ const OpenApi3_0DereferenceVisitor = stampit({
406
420
// possibly non-semantic referenced element
407
421
const jsonPointer = uriToPointer ( toValue ( linkElement . operationRef ) ) ;
408
422
const retrievalURI = this . toBaseURI ( toValue ( linkElement . operationRef ) ) ;
423
+ const isInternalReference = url . stripHash ( this . reference . uri ) === retrievalURI ;
424
+ const isExternalReference = ! isInternalReference ;
409
425
426
+ // ignore resolving internal Operation Object reference
427
+ if ( ! this . options . resolve . internal && isInternalReference ) {
428
+ // skip traversing this Link element but traverse all it's child elements
429
+ return undefined ;
430
+ }
410
431
// ignore resolving external Operation Object reference
411
- if ( ! this . options . resolve . external && url . stripHash ( this . reference . uri ) !== retrievalURI ) {
432
+ if ( ! this . options . resolve . external && isExternalReference ) {
412
433
// skip traversing this Link element but traverse all it's child elements
413
434
return undefined ;
414
435
}
@@ -485,9 +506,16 @@ const OpenApi3_0DereferenceVisitor = stampit({
485
506
}
486
507
487
508
const retrievalURI = this . toBaseURI ( toValue ( exampleElement . externalValue ) ) ;
509
+ const isInternalReference = url . stripHash ( this . reference . uri ) === retrievalURI ;
510
+ const isExternalReference = ! isInternalReference ;
488
511
489
512
// ignore resolving external Example Objects
490
- if ( ! this . options . resolve . external && url . stripHash ( this . reference . uri ) !== retrievalURI ) {
513
+ if ( ! this . options . resolve . internal && isInternalReference ) {
514
+ // skip traversing this Example element but traverse all it's child elements
515
+ return undefined ;
516
+ }
517
+ // ignore resolving external Example Objects
518
+ if ( ! this . options . resolve . external && isExternalReference ) {
491
519
// skip traversing this Example element but traverse all it's child elements
492
520
return undefined ;
493
521
}
0 commit comments