Skip to content

refactor(reference): align naming with OpenAPI 3.0.4 #4626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ class OpenAPI2DereferenceVisitor {
*
* Cases to consider:
* 1. We're crossing document boundary
* 2. Fragment is from non-root document
* 2. Fragment is from non-entry document
* 3. Fragment is a Reference Object. We need to follow it to get the eventual value
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
*/
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
if (
(isExternalReference ||
isNonRootDocument ||
isNonEntryDocument ||
isReferenceElement(referencedElement) ||
shouldDetectCircular) &&
!ancestorsLineage.includesCycle(referencedElement)
Expand Down Expand Up @@ -432,15 +432,15 @@ class OpenAPI2DereferenceVisitor {
*
* Cases to consider:
* 1. We're crossing document boundary
* 2. Fragment is from non-root document
* 3. Fragment is a Paht Item Object with $ref field. We need to follow it to get the eventual value
* 2. Fragment is from non-entry document
* 3. Fragment is a Path Item Object with $ref field. We need to follow it to get the eventual value
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
*/
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
if (
(isExternalReference ||
isNonRootDocument ||
isNonEntryDocument ||
(isPathItemElement(referencedElement) && isStringElement(referencedElement.$ref)) ||
shouldDetectCircular) &&
!ancestorsLineage.includesCycle(referencedElement)
Expand Down Expand Up @@ -612,15 +612,15 @@ class OpenAPI2DereferenceVisitor {
*
* Cases to consider:
* 1. We're crossing document boundary
2. Fragment is from non-root document
2. Fragment is from non-entry document
* 3. Fragment is a JSON Reference Object. We need to follow it to get the eventual value
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
*/
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
if (
(isExternalReference ||
isNonRootDocument ||
isNonEntryDocument ||
isJSONReferenceElement(referencedElement) ||
shouldDetectCircular) &&
!ancestorsLineage.includesCycle(referencedElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ class OpenAPI3_0DereferenceVisitor {
*
* Cases to consider:
* 1. We're crossing document boundary
* 2. Fragment is from non-root document
* 2. Fragment is from non-entry document
* 3. Fragment is a Reference Object. We need to follow it to get the eventual value
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
*/
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
if (
(isExternalReference ||
isNonRootDocument ||
isNonEntryDocument ||
isReferenceElement(referencedElement) ||
shouldDetectCircular) &&
!ancestorsLineage.includesCycle(referencedElement)
Expand Down Expand Up @@ -433,15 +433,15 @@ class OpenAPI3_0DereferenceVisitor {
*
* Cases to consider:
* 1. We're crossing document boundary
* 2. Fragment is from non-root document
* 2. Fragment is from non-entry document
* 3. Fragment is a Path Item Object with $ref field. We need to follow it to get the eventual value
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
*/
const isNonRootDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const isNonEntryDocument = url.stripHash(reference.refSet!.rootRef!.uri) !== reference.uri;
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
if (
(isExternalReference ||
isNonRootDocument ||
isNonEntryDocument ||
(isPathItemElement(referencedElement) && isStringElement(referencedElement.$ref)) ||
shouldDetectCircular) &&
!ancestorsLineage.includesCycle(referencedElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('dereference', function () {
context('apidom', function () {
context('remote', function () {
specify('should substitute Ref Element with the Element it references', async function () {
const uri = path.join(__dirname, 'fixtures', 'substitute', 'root.json');
const uri = path.join(__dirname, 'fixtures', 'substitute', 'entry.json');
const actual = await dereference(uri, {
parse: { mediaType: 'application/vnd.apidom' },
});
Expand All @@ -24,7 +24,7 @@ describe('dereference', function () {
specify(
'should process Ref Element nested in remote referenced element',
async function () {
const uri = path.join(__dirname, 'fixtures', 'nested', 'root.json');
const uri = path.join(__dirname, 'fixtures', 'nested', 'entry.json');
const actual = await dereference(uri, {
parse: { mediaType: 'application/vnd.apidom' },
});
Expand All @@ -37,7 +37,7 @@ describe('dereference', function () {

context('given external resolution disabled', function () {
specify('should not dereference', async function () {
const uri = path.join(__dirname, 'fixtures', 'external-disabled', 'root.json');
const uri = path.join(__dirname, 'fixtures', 'external-disabled', 'entry.json');
const actual = await dereference(uri, {
parse: { mediaType: 'application/vnd.apidom' },
resolve: { external: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('resolve', function () {
context('local', function () {
context('resolve', function () {
specify('should resolve', async function () {
const uri = path.resolve(__dirname, 'fixtures', 'root.json');
const uri = path.resolve(__dirname, 'fixtures', 'entry.json');
const refSet = await resolve(uri, {
parse: { mediaType: 'application/vnd.apidom' },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('dereference', function () {
});
const refSet = await resolveApiDOM(element, {
parse: { mediaType: 'application/vnd.apidom' },
resolve: { baseURI: path.join(__dirname, 'fixtures', 'root.json') },
resolve: { baseURI: path.join(__dirname, 'fixtures', 'entry.json') },
});

assert.strictEqual(refSet.size, 2);
Expand Down
Loading