diff --git a/lib/schemaUtils.js b/lib/schemaUtils.js index f1f71cf..87f0565 100644 --- a/lib/schemaUtils.js +++ b/lib/schemaUtils.js @@ -4864,10 +4864,16 @@ module.exports = { if (rootFormat.toLowerCase() === parse.YAML_FORMAT) { bundledFile = parse.toYAML(bundledFile); } + else if (rootFormat.toLowerCase() === parse.JSON_FORMAT) { + bundledFile = parse.toJSON(bundledFile, null); + } } else if (format.toLowerCase() === parse.YAML_FORMAT) { bundledFile = parse.toYAML(bundledFile); } + else if (format.toLowerCase() === parse.JSON_FORMAT) { + bundledFile = parse.toJSON(bundledFile, null); + } return { rootFile: { path: contentAndComponents.fileName }, bundledContent: bundledFile }; }; }, diff --git a/test/unit/bundle.test.js b/test/unit/bundle.test.js index d5bea4b..3a9c834 100644 --- a/test/unit/bundle.test.js +++ b/test/unit/bundle.test.js @@ -70,7 +70,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; expect(res.output.specification.version).to.equal('3.0'); - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file as yaml - schema_from_response', async function () { @@ -190,7 +190,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); @@ -238,7 +238,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - petstore separated example', async function () { @@ -382,7 +382,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - with_ref_in_items', async function () { @@ -419,7 +419,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return error data - with_ref_in_items - wrong root', async function () { @@ -510,7 +510,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - multiple_references_from_root_components', async function () { @@ -582,7 +582,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file as json - bring_local_dependencies_from_external', async function () { @@ -614,7 +614,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file as json - bring_local_dependencies_from_external_multiple_local', async function () { @@ -651,7 +651,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return a "/missing/node/path": NotProvided' + @@ -694,7 +694,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced tags from root', async function () { @@ -726,7 +726,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced info from root', async function () { @@ -758,7 +758,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced paths from root', async function () { @@ -795,7 +795,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced paths from root - path references local schema', async function () { @@ -832,7 +832,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should throw error when root files is undefined and in data there is no root file', async function () { @@ -902,7 +902,7 @@ describe('bundle files method - 3.0', function () { const res = await Converter.bundle(input); expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should throw error when root files is empty array and in data there is no root file', async function () { @@ -987,8 +987,8 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); - expect(JSON.stringify(res.output.data[1].bundledContent, null, 2)).to.be.equal(expected2); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[1].bundledContent), null, 2)).to.be.equal(expected2); expect(res.output.data[0].rootFile.path).to.equal('/root.yaml'); expect(res.output.data[1].rootFile.path).to.equal('/root2.yaml'); }); @@ -1073,7 +1073,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); expect(res.output.data.length).to.equal(1); }); @@ -1116,7 +1116,7 @@ describe('bundle files method - 3.0', function () { expect(res.result).to.be.true; expect(res.output.specification.version).to.equal('3.1'); expect(res.output.data.length).to.equal(1); - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should bundle only the files with the specified version 3.0', async function () { @@ -1158,7 +1158,7 @@ describe('bundle files method - 3.0', function () { expect(res.result).to.be.true; expect(res.output.specification.version).to.equal('3.0'); expect(res.output.data.length).to.equal(1); - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('should bundle files to 3.0 when specificationVersion is not provided', async function () { @@ -1199,7 +1199,7 @@ describe('bundle files method - 3.0', function () { expect(res.result).to.be.true; expect(res.output.specification.version).to.equal('3.0'); expect(res.output.data.length).to.equal(1); - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced example', async function () { @@ -1231,7 +1231,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); expect(res.output.data.length).to.equal(1); }); @@ -1341,7 +1341,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); expect(res.output.data.length).to.equal(1); }); @@ -1399,7 +1399,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); expect(res.output.data.length).to.equal(1); }); @@ -1437,7 +1437,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); expect(res.output.data.length).to.equal(1); }); @@ -1480,7 +1480,7 @@ describe('bundle files method - 3.0', function () { expect(res.result).to.be.true; expect(res.output.specification.version).to.equal('3.0'); expect(res.output.data.length).to.equal(2); - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expectedJSON); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expectedJSON); expect(res.output.data[1].bundledContent).to.be.equal(expectedYAML); }); @@ -1528,7 +1528,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced response', async function () { @@ -1560,7 +1560,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced Parameter', async function () { @@ -1592,7 +1592,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced Request Body', async function () { @@ -1624,7 +1624,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced Header', async function () { @@ -1656,7 +1656,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced Link', async function () { @@ -1688,7 +1688,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced Callback', async function () { @@ -1720,7 +1720,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced Security Schemes', async function () { @@ -1752,7 +1752,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should bundle file from - additionalProperties', async function() { @@ -1788,7 +1788,7 @@ describe('bundle files method - 3.0', function () { const res = await Converter.bundle(input); expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should bundle composite file with oneOf - composite_oneOf', async function() { @@ -1825,7 +1825,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should bundle composite file with anyOf - composite_anyOf', async function() { @@ -1862,7 +1862,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should bundle composite file with not - composite_not', async function() { @@ -1894,7 +1894,7 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should throw error when version is not correct', async function () { diff --git a/test/unit/bundle20.test.js b/test/unit/bundle20.test.js index 483c028..476a712 100644 --- a/test/unit/bundle20.test.js +++ b/test/unit/bundle20.test.js @@ -80,7 +80,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - sameRefDifferentSource', async function() { @@ -137,7 +137,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - multipleRefFromRootComponents', async function() { @@ -184,7 +184,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - bringLocalDependenciesFromExternalMultiple', async function() { @@ -236,7 +236,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - bringLocalDependenciesFromExternalWithItems', async function() { @@ -278,7 +278,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - bringLocalDependenciesFromExternal', async function() { @@ -320,7 +320,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - withParametersAndItems', async function() { @@ -367,7 +367,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - nestedLocalRef', async function() { @@ -414,7 +414,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - nestedRefs', async function() { @@ -461,7 +461,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - basicExample', async function() { @@ -498,7 +498,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled result from - simpleRef', async function() { @@ -540,7 +540,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced tags from root', async function () { @@ -572,7 +572,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced paths from root', async function () { @@ -609,7 +609,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced paths from root - path references local schema', async function () { @@ -646,7 +646,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file with referenced example', async function () { @@ -678,7 +678,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file from - petstore-separated-yaml (contains allOf)', async function() { @@ -724,7 +724,7 @@ describe('bundle files method - 2.0', function() { const res = await Converter.bundle(input); expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should bundle file from - additionalProperties 2.0', async function() { @@ -760,7 +760,7 @@ describe('bundle files method - 2.0', function() { const res = await Converter.bundle(input); expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file - referenced Security Schemes', async function () { @@ -792,7 +792,7 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should bundle file from - referenced response 2.0', async function() { @@ -824,6 +824,6 @@ describe('bundle files method - 2.0', function() { expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); }); diff --git a/test/unit/bundle31.test.js b/test/unit/bundle31.test.js index f4d6894..6fe0e4b 100644 --- a/test/unit/bundle31.test.js +++ b/test/unit/bundle31.test.js @@ -38,7 +38,7 @@ describe('bundle files method - 3.1', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; expect(res.output.specification.version).to.equal('3.1'); - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); it('Should return bundled file as json - webhook object', async function () { @@ -71,6 +71,6 @@ describe('bundle files method - 3.1', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; expect(res.output.specification.version).to.equal('3.1'); - expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); });