Skip to content
Open
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,31 @@
[
{
"asyncapi": "3.0.0",
"components": {
"schemas": {
"multiFormatSchema1": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
},
"multiFormatSchema2": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"asyncapi": "3.0.0",
"components": {
"schemas": {
"multiFormatSchema1": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
},
"multiFormatSchema2": {
"$ref": "#/components/schemas/multiFormatSchema1"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"asyncapi": "3.0.0",
"components": {
"schemas": {
"multiFormatSchema1": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
},
"multiFormatSchema2": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "string"
}
}
},
"messages": {
"message1": {
"headers": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
},
"payload": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "string"
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"asyncapi": "3.0.0",
"components": {
"schemas": {
"multiFormatSchema1": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
},
"multiFormatSchema2": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "string"
}
}
},
"messages": {
"message1": {
"headers": {
"$ref": "#/components/schemas/multiFormatSchema1"
},
"payload": {
"$ref": "#/components/schemas/multiFormatSchema2"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"asyncapi": "3.0.0",
"components": {
"schemas": {
"multiFormatSchema1": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
}
},
"messageTraits": {
"messageTrait1": {
"headers": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
}
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"asyncapi": "3.0.0",
"components": {
"schemas": {
"multiFormatSchema1": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": {
"type": "object",
"properties": {
"property1": {
"type": "string"
}
}
}
}
},
"messageTraits": {
"messageTrait1": {
"headers": {
"$ref": "#/components/schemas/multiFormatSchema1"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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('Multi Format Schema Object', function () {
context('given in Message Object', function () {
const fixturePath = path.join(rootFixturePath, 'message-object');

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 Message Trait Object', function () {
const fixturePath = path.join(rootFixturePath, 'message-trait-object');

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/schemas field', function () {
const fixturePath = path.join(rootFixturePath, 'components-schemas');

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);
});
});
});
});
});
});
Loading