Fix defintions replacing instead of merging

Fix defintions replacing instead of merging
This commit is contained in:
Luis Tejeda
2022-06-01 14:09:35 -05:00
parent 6fa20ccb48
commit d289dd0fdc
10 changed files with 214 additions and 14 deletions

View File

@@ -28,7 +28,8 @@ let expect = require('chai').expect,
refTags20 = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/referenced_tags'),
basicExample = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/basicExample'),
simpleRef = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/simpleRef'),
refPaths20 = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/referenced_paths');
refPaths20 = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/referenced_paths'),
refPathsRefToLocalSchema20 = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/referenced_paths_local_schema');
describe('bundle files method - 3.0', function () {
it('Should return bundled file as json - schema_from_response', async function () {
@@ -913,6 +914,39 @@ describe('bundle files method - 2.0', function () {
expect(res.result).to.be.true;
expect(res.output.data.bundledContent).to.be.equal(expected);
});
it('Should return bundled file with referenced paths from root - path references local schema', async function () {
let contentRootFile = fs.readFileSync(refPathsRefToLocalSchema20 + '/root.yaml', 'utf8'),
paths = fs.readFileSync(refPathsRefToLocalSchema20 + '/paths/paths.yaml', 'utf8'),
path = fs.readFileSync(refPathsRefToLocalSchema20 + '/paths/path.yaml', 'utf8'),
expected = fs.readFileSync(refPathsRefToLocalSchema20 + '/expected.json', 'utf8'),
input = {
type: 'folder',
specificationVersion: '2.0',
rootFiles: [
{
path: '/root.yaml',
content: contentRootFile
}
],
data: [
{
path: '/paths/paths.yaml',
content: paths
},
{
path: '/paths/path.yaml',
content: path
}
],
options: {},
bundleFormat: 'JSON'
};
const res = await Converter.bundle(input);
expect(res).to.not.be.empty;
expect(res.result).to.be.true;
expect(res.output.data.bundledContent).to.be.equal(expected);
});
});
describe('getReferences method when node does not have any reference', function() {