Skip to content
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
@@ -0,0 +1,15 @@
[
{
"asyncapi": "3.0.0",
"components": {
"serverVariables": {
"variable1": {
"enum": ["a", "b", "c"]
},
"variable2": {
"enum": ["a", "b", "c"]
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"asyncapi": "3.0.0",
"components": {
"serverVariables": {
"variable1": {
"enum": ["a", "b", "c"]
},
"variable2": {
"$ref": "#/components/serverVariables/variable1"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"asyncapi": "3.0.0",
"components": {
"servers": {
"server1": {
"host": "http://example.com",
"protocol": "protocol",
"variables": {
"variable1": {
"enum": ["a", "b", "c"]
},
"variable2": {
"enum": ["a", "b", "c"]
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"asyncapi": "3.0.0",
"components": {
"servers": {
"server1": {
"host": "http://example.com",
"protocol": "protocol",
"variables": {
"variable1": {
"enum": ["a", "b", "c"]
},
"variable2": {
"$ref": "#/components/servers/server1/variables/variable1"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import path from 'node:path';
import { assert } from 'chai';
import { toValue } from '@swagger-api/apidom-core';
import { mediaTypes } from '@swagger-api/apidom-ns-asyncapi-3';
import { fileURLToPath } from 'node:url';

import { loadJsonFile } from '../../../../helpers.ts';
import { dereference } from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootFixturePath = path.join(__dirname, 'fixtures');

describe('dereference', function () {
context('strategies', function () {
context('asyncapi-3', function () {
context('ServerVariable Object', function () {
context('given in server/variables field', function () {
const fixturePath = path.join(rootFixturePath, 'server-variables');

specify('should dereference', async function () {
const rootFilePath = path.join(fixturePath, 'root.json');
const actual = await dereference(rootFilePath, {
parse: { mediaType: mediaTypes.latest('json') },
});
const expected = loadJsonFile(path.join(fixturePath, 'dereferenced.json'));

assert.deepEqual(toValue(actual), expected);
});
});

context('given in components/serverVariables field', function () {
const fixturePath = path.join(rootFixturePath, 'components-server-variables');

specify('should dereference', async function () {
const rootFilePath = path.join(fixturePath, 'root.json');
const actual = await dereference(rootFilePath, {
parse: { mediaType: mediaTypes.latest('json') },
});
const expected = loadJsonFile(path.join(fixturePath, 'dereferenced.json'));

assert.deepEqual(toValue(actual), expected);
});
});
});
});
});
});