Skip to content

Commit 2026f56

Browse files
committed
fix: simplify self-file reference check
1 parent 06355bd commit 2026f56

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

__tests__/bundle/self-file-ref-normalization/openapi.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ openapi: 3.0.0
22
info:
33
title: Self-file ref normalization
44
version: 1.0.0
5-
license:
6-
name: MIT
75
servers:
86
- url: http://example.com
97
security: []
108
paths:
119
/test:
1210
get:
13-
summary: Test
14-
operationId: getTest
1511
parameters:
1612
- $ref: 'openapi.yaml#/components/parameters/myParam'
1713
responses:

__tests__/bundle/self-file-ref-normalization/snapshot.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ openapi: 3.0.0
22
info:
33
title: Self-file ref normalization
44
version: 1.0.0
5-
license:
6-
name: MIT
75
servers:
86
- url: http://example.com
97
security: []
108
paths:
119
/test:
1210
get:
13-
summary: Test
14-
operationId: getTest
1511
parameters:
1612
- $ref: '#/components/parameters/myParam'
1713
responses:

packages/core/src/bundle.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,15 @@ function makeBundleVisitor(
339339
return;
340340
}
341341

342-
// Normalize explicit self-file refs to internal pointer
343-
if (ctx.location.source.absoluteRef === resolved.location.source.absoluteRef) {
344-
node.$ref = resolved.location.pointer;
345-
}
346-
347342
if (
348343
resolved.location.source === rootDocument.source &&
349344
resolved.location.source === ctx.location.source &&
350345
ctx.type.name !== 'scalar' &&
351346
!dereference
352347
) {
348+
// Normalize explicit self-file refs to internal pointer
349+
node.$ref = resolved.location.pointer;
350+
353351
return;
354352
}
355353

0 commit comments

Comments
 (0)