Skip to content

Commit

Permalink
refactor(reference): align OpenAPI 2.0 naming strategies with spec (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Dec 26, 2024
1 parent 0dcb105 commit 7341bf3
Show file tree
Hide file tree
Showing 126 changed files with 418 additions and 417 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('dereference', function () {
'given single JSONReferenceElement passed to dereferenceApiDOM with internal references',
function () {
context('given dereferencing using local file system', function () {
const fixturePath = path.join(__dirname, 'fixtures', 'internal-only', 'root.json');
const fixturePath = path.join(__dirname, 'fixtures', 'internal-only', 'entry.json');

specify('should dereference', async function () {
const parseResult = await parse(fixturePath, {
Expand Down Expand Up @@ -53,13 +53,13 @@ describe('dereference', function () {

assert.match(
toValue(dereferenced.meta.get('ref-origin')),
/internal-only\/root\.json$/,
/internal-only\/entry\.json$/,
);
});
});

context('given dereferencing using HTTP protocol', function () {
const fixturePath = path.join(__dirname, 'fixtures', 'internal-only', 'root.json');
const fixturePath = path.join(__dirname, 'fixtures', 'internal-only', 'entry.json');
const httpPort = 8123;
let httpServer: ServerTerminable;

Expand All @@ -83,7 +83,7 @@ describe('dereference', function () {
const dereferenced = await dereferenceApiDOM(referenceElement, {
parse: { mediaType: mediaTypes.latest('json') },
resolve: {
baseURI: `http://localhost:${httpPort}/root.json#/definitions/schema1`,
baseURI: `http://localhost:${httpPort}/entry.json#/definitions/schema1`,
},
});

Expand All @@ -101,11 +101,11 @@ describe('dereference', function () {
const dereferenced = await dereferenceApiDOM(referenceElement, {
parse: { mediaType: mediaTypes.latest('json') },
resolve: {
baseURI: `http://localhost:${httpPort}/root.json#/definitions/schema1`,
baseURI: `http://localhost:${httpPort}/entry.json#/definitions/schema1`,
},
});

assert.match(toValue(dereferenced.meta.get('ref-origin')), /\/root\.json$/);
assert.match(toValue(dereferenced.meta.get('ref-origin')), /\/entry\.json$/);
});
});
},
Expand All @@ -115,7 +115,7 @@ describe('dereference', function () {
'given single JSONReferenceElement passed to dereferenceApiDOM with external references',
function () {
context('given dereferencing using local file system', function () {
const fixturePath = path.join(__dirname, 'fixtures', 'external-only', 'root.json');
const fixturePath = path.join(__dirname, 'fixtures', 'external-only', 'entry.json');

specify('should dereference', async function () {
const parseResult = await parse(fixturePath, {
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('dereference', function () {
});

context('given dereferencing using HTTP protocol', function () {
const fixturePath = path.join(__dirname, 'fixtures', 'external-only', 'root.json');
const fixturePath = path.join(__dirname, 'fixtures', 'external-only', 'entry.json');
const httpPort = 8123;
let httpServer: ServerTerminable;

Expand All @@ -177,7 +177,7 @@ describe('dereference', function () {
);
const dereferenced = await dereferenceApiDOM(referenceElement, {
parse: { mediaType: mediaTypes.latest('json') },
resolve: { baseURI: `http://localhost:${httpPort}/root.json` },
resolve: { baseURI: `http://localhost:${httpPort}/entry.json` },
});

assert.isTrue(isSchemaElement(dereferenced));
Expand All @@ -193,7 +193,7 @@ describe('dereference', function () {
);
const dereferenced = await dereferenceApiDOM(referenceElement, {
parse: { mediaType: mediaTypes.latest('json') },
resolve: { baseURI: `http://localhost:${httpPort}/root.json` },
resolve: { baseURI: `http://localhost:${httpPort}/entry.json` },
});

assert.match(toValue(dereferenced.meta.get('ref-origin')), /\/ex\.json$/);
Expand All @@ -205,7 +205,7 @@ describe('dereference', function () {
__dirname,
'fixtures',
'external-only-absolute-url',
'root.json',
'entry.json',
);
const httpPort = 8123;
let httpServer: ServerTerminable;
Expand All @@ -229,7 +229,7 @@ describe('dereference', function () {
);
const dereferenced = await dereferenceApiDOM(referenceElement, {
parse: { mediaType: mediaTypes.latest('json') },
resolve: { baseURI: `http://localhost:${httpPort}/root.json` },
resolve: { baseURI: `http://localhost:${httpPort}/entry.json` },
});

assert.isTrue(isSchemaElement(dereferenced));
Expand All @@ -245,7 +245,7 @@ describe('dereference', function () {
);
const dereferenced = await dereferenceApiDOM(referenceElement, {
parse: { mediaType: mediaTypes.latest('json') },
resolve: { baseURI: `http://localhost:${httpPort}/root.json` },
resolve: { baseURI: `http://localhost:${httpPort}/entry.json` },
});

assert.match(toValue(dereferenced.meta.get('ref-origin')), /\/ex\.json$/);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"definitions": {
"externalSchema": {
"$ref": "./root.json#/definitions/schema"
"$ref": "./entry.json#/definitions/schema"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"definitions": {
"externalSchema1": {
"$ref": "./root.json#/definitions/schema2"
"$ref": "./entry.json#/definitions/schema2"
},
"externalSchema2": {
"$ref": "./root.json#/definitions/schema2"
"$ref": "./entry.json#/definitions/schema2"
},
"externalSchema3": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"definitions": {
"indirection": {
"$ref": "./root.json#/definitions/schema"
"$ref": "./entry.json#/definitions/schema"
}
}
}
Loading

0 comments on commit 7341bf3

Please sign in to comment.