Skip to content

Commit 7f5fb81

Browse files
authored
refactor(reference): align naming with OpenAPI 3.0.4 (#4626)
Root document became entry document. Refs #4612
1 parent 7341bf3 commit 7f5fb81

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

packages/apidom-reference/src/dereference/strategies/openapi-2/visitor.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,15 @@ class OpenAPI2DereferenceVisitor {
267267
*
268268
* Cases to consider:
269269
* 1. We're crossing document boundary
270-
* 2. Fragment is from non-root document
270+
* 2. Fragment is from non-entry document
271271
* 3. Fragment is a Reference Object. We need to follow it to get the eventual value
272272
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
273273
*/
274-
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
274+
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
275275
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
276276
if (
277277
(isExternalReference ||
278-
isNonRootDocument ||
278+
isNonEntryDocument ||
279279
isReferenceElement(referencedElement) ||
280280
shouldDetectCircular) &&
281281
!ancestorsLineage.includesCycle(referencedElement)
@@ -432,15 +432,15 @@ class OpenAPI2DereferenceVisitor {
432432
*
433433
* Cases to consider:
434434
* 1. We're crossing document boundary
435-
* 2. Fragment is from non-root document
436-
* 3. Fragment is a Paht Item Object with $ref field. We need to follow it to get the eventual value
435+
* 2. Fragment is from non-entry document
436+
* 3. Fragment is a Path Item Object with $ref field. We need to follow it to get the eventual value
437437
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
438438
*/
439-
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
439+
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
440440
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
441441
if (
442442
(isExternalReference ||
443-
isNonRootDocument ||
443+
isNonEntryDocument ||
444444
(isPathItemElement(referencedElement) && isStringElement(referencedElement.$ref)) ||
445445
shouldDetectCircular) &&
446446
!ancestorsLineage.includesCycle(referencedElement)
@@ -612,15 +612,15 @@ class OpenAPI2DereferenceVisitor {
612612
*
613613
* Cases to consider:
614614
* 1. We're crossing document boundary
615-
2. Fragment is from non-root document
615+
2. Fragment is from non-entry document
616616
* 3. Fragment is a JSON Reference Object. We need to follow it to get the eventual value
617617
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
618618
*/
619-
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
619+
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
620620
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
621621
if (
622622
(isExternalReference ||
623-
isNonRootDocument ||
623+
isNonEntryDocument ||
624624
isJSONReferenceElement(referencedElement) ||
625625
shouldDetectCircular) &&
626626
!ancestorsLineage.includesCycle(referencedElement)

packages/apidom-reference/src/dereference/strategies/openapi-3-0/visitor.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ class OpenAPI3_0DereferenceVisitor {
269269
*
270270
* Cases to consider:
271271
* 1. We're crossing document boundary
272-
* 2. Fragment is from non-root document
272+
* 2. Fragment is from non-entry document
273273
* 3. Fragment is a Reference Object. We need to follow it to get the eventual value
274274
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
275275
*/
276-
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
276+
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
277277
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
278278
if (
279279
(isExternalReference ||
280-
isNonRootDocument ||
280+
isNonEntryDocument ||
281281
isReferenceElement(referencedElement) ||
282282
shouldDetectCircular) &&
283283
!ancestorsLineage.includesCycle(referencedElement)
@@ -433,15 +433,15 @@ class OpenAPI3_0DereferenceVisitor {
433433
*
434434
* Cases to consider:
435435
* 1. We're crossing document boundary
436-
* 2. Fragment is from non-root document
436+
* 2. Fragment is from non-entry document
437437
* 3. Fragment is a Path Item Object with $ref field. We need to follow it to get the eventual value
438438
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
439439
*/
440-
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
440+
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
441441
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
442442
if (
443443
(isExternalReference ||
444-
isNonRootDocument ||
444+
isNonEntryDocument ||
445445
(isPathItemElement(referencedElement) && isStringElement(referencedElement.$ref)) ||
446446
shouldDetectCircular) &&
447447
!ancestorsLineage.includesCycle(referencedElement)

packages/apidom-reference/test/dereference/strategies/apidom/remote/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('dereference', function () {
1212
context('apidom', function () {
1313
context('remote', function () {
1414
specify('should substitute Ref Element with the Element it references', async function () {
15-
const uri = path.join(__dirname, 'fixtures', 'substitute', 'root.json');
15+
const uri = path.join(__dirname, 'fixtures', 'substitute', 'entry.json');
1616
const actual = await dereference(uri, {
1717
parse: { mediaType: 'application/vnd.apidom' },
1818
});
@@ -24,7 +24,7 @@ describe('dereference', function () {
2424
specify(
2525
'should process Ref Element nested in remote referenced element',
2626
async function () {
27-
const uri = path.join(__dirname, 'fixtures', 'nested', 'root.json');
27+
const uri = path.join(__dirname, 'fixtures', 'nested', 'entry.json');
2828
const actual = await dereference(uri, {
2929
parse: { mediaType: 'application/vnd.apidom' },
3030
});
@@ -37,7 +37,7 @@ describe('dereference', function () {
3737

3838
context('given external resolution disabled', function () {
3939
specify('should not dereference', async function () {
40-
const uri = path.join(__dirname, 'fixtures', 'external-disabled', 'root.json');
40+
const uri = path.join(__dirname, 'fixtures', 'external-disabled', 'entry.json');
4141
const actual = await dereference(uri, {
4242
parse: { mediaType: 'application/vnd.apidom' },
4343
resolve: { external: false },

packages/apidom-reference/test/resolve/strategies/apidom/local/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('resolve', function () {
1313
context('local', function () {
1414
context('resolve', function () {
1515
specify('should resolve', async function () {
16-
const uri = path.resolve(__dirname, 'fixtures', 'root.json');
16+
const uri = path.resolve(__dirname, 'fixtures', 'entry.json');
1717
const refSet = await resolve(uri, {
1818
parse: { mediaType: 'application/vnd.apidom' },
1919
});

packages/apidom-reference/test/resolve/strategies/apidom/remote/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('dereference', function () {
1818
});
1919
const refSet = await resolveApiDOM(element, {
2020
parse: { mediaType: 'application/vnd.apidom' },
21-
resolve: { baseURI: path.join(__dirname, 'fixtures', 'root.json') },
21+
resolve: { baseURI: path.join(__dirname, 'fixtures', 'entry.json') },
2222
});
2323

2424
assert.strictEqual(refSet.size, 2);

0 commit comments

Comments
 (0)