From 2faa3fde09e73ba9656439cd326c2b6755c77993 Mon Sep 17 00:00:00 2001 From: Luis Tejeda <46000487+LuisTejedaS@users.noreply.github.com> Date: Wed, 22 Jun 2022 11:27:14 -0500 Subject: [PATCH 1/5] avoid reading from fs --- lib/bundle.js | 2 +- lib/parse.js | 6 ++++-- lib/schemapack.js | 12 +++++------ test/unit/bundle.test.js | 39 ++++++++++++++++++++++++++++++++++++ test/unit/detectRoot.test.js | 25 +++++++++++++++++++++-- 5 files changed, 73 insertions(+), 11 deletions(-) diff --git a/lib/bundle.js b/lib/bundle.js index 06f6bed..211f5d8 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -334,7 +334,7 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver return value.keyInComponents.length !== 0; }); notInLine.forEach(([key, value]) => { - let [, partial] = key.split('#'); + let [, partial] = key.split(localPointer); setValueInComponents( value.keyInComponents, components, diff --git a/lib/parse.js b/lib/parse.js index 80ff638..5923d34 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -96,9 +96,11 @@ module.exports = { * @param {Object} options computed process options * @param {Object} files Files map * @param {string} specificationVersion the string of the desired version + * @param {boolean} allowReadingFS wheter to allow reading content from file system * @return {String} rootFile */ - getRootFiles: function (input, inputValidation, options, files = {}, specificationVersion) { + getRootFiles: function (input, inputValidation, options, files = {}, specificationVersion, + allowReadingFS = true) { let rootFilesArray = [], filesPathArray = input.data, origin = input.origin || ''; @@ -114,7 +116,7 @@ module.exports = { if (!_.isEmpty(files)) { file = files[path.resolve(filePath.fileName)]; } - else { + else if (allowReadingFS) { file = fs.readFileSync(filePath.fileName, 'utf8'); } diff --git a/lib/schemapack.js b/lib/schemapack.js index 8a1470b..34a26dd 100644 --- a/lib/schemapack.js +++ b/lib/schemapack.js @@ -644,15 +644,15 @@ class SchemaPack { path = pathBrowserify; OasResolverOptions.browser = true; } - if ('content' in input.data[0]) { - input.data.forEach((file) => { - files[path.resolve(file.fileName)] = file.content ? file.content : ''; - }); - } + // if ('content' in input.data[0]) { + input.data.forEach((file) => { + files[path.resolve(file.fileName)] = file.content ? file.content : ''; + }); + // } adaptedInput = schemaUtils.mapDetectRootFilesInputToGetRootFilesInput(input); adaptedInput.origin = input.origin; rootFiles = parse.getRootFiles(adaptedInput, concreteUtils.inputValidation, this.computedOptions, files, - input.specificationVersion); + input.specificationVersion, false); res = schemaUtils.mapGetRootFilesOutputToDetectRootFilesOutput(rootFiles, input.specificationVersion); return res; } diff --git a/test/unit/bundle.test.js b/test/unit/bundle.test.js index dfb5330..04cbecf 100644 --- a/test/unit/bundle.test.js +++ b/test/unit/bundle.test.js @@ -1933,6 +1933,45 @@ describe('bundle files method - 3.0', function () { expect(error.message).to.equal('The provided version "Anything" is not valid'); } }); + + + it('should ignore reference when is empty content', async function() { + let input = + { + type: 'multiFile', + specificationVersion: '3.0', + bundleFormat: 'JSON', + data: [ + { + path: 'hello.yaml', + content: '' + }, + { + path: 'openapi.yaml', + content: 'openapi: 3.0.0\n' + + 'info:\n' + + ' title: hello world\n' + + ' version: 0.1.1\n' + + 'paths:\n' + + ' /hello:\n' + + ' get:\n' + + ' summary: get the hello\n' + + ' responses:\n' + + ' 200:\n' + + ' description: sample des\n' + + ' content:\n' + + ' application/json:\n' + + ' schema:\n' + + ' $ref: \'./hello.yaml\'' + } + ] + }; + const res = await Converter.bundle(input); + expect(res).to.not.be.empty; + expect(res.result).to.be.true; + expect(res.output.specification.version).to.equal('3.0'); + }); + }); diff --git a/test/unit/detectRoot.test.js b/test/unit/detectRoot.test.js index 34b07f9..d7cc681 100644 --- a/test/unit/detectRoot.test.js +++ b/test/unit/detectRoot.test.js @@ -246,7 +246,7 @@ describe('detectRoot method', function() { expect(res.output.data[0].path).to.equal('/swagger.json'); }); - it('should read content when is not present 3.0 and no specific version', async function () { + it('should not read content from FS when is not present', async function () { let input = { type: 'multiFile', specificationVersion: '3.1.0', @@ -262,7 +262,7 @@ describe('detectRoot method', function() { const res = await Converter.detectRootFiles(input); expect(res).to.not.be.empty; expect(res.result).to.be.true; - expect(res.output.data[0].path).to.equal(validHopService31x); + expect(res.output.data.length).to.equal(0); }); @@ -307,4 +307,25 @@ describe('detectRoot method', function() { } }); + it('should not read content from FS when is not present ', async function () { + let petSchema = fs.readFileSync(petstoreSeparatedPet, 'utf8'), + input = { + type: 'multiFile', + specificationVersion: '3.0', + data: [ + { + path: validPetstore + }, + { + path: '/Pet.yaml', + content: petSchema + } + ] + }; + const res = await Converter.detectRootFiles(input); + expect(res).to.not.be.empty; + expect(res.result).to.be.true; + expect(res.output.data.length).to.equal(0); + + }); }); From eed8a2c5d3395040d1991c97045ba72afca07a92 Mon Sep 17 00:00:00 2001 From: Luis Tejeda <46000487+LuisTejedaS@users.noreply.github.com> Date: Wed, 22 Jun 2022 17:49:31 -0500 Subject: [PATCH 2/5] ignore invalid nodes ignore invalid nodes --- bundled.json | 1 + lib/bundle.js | 90 +++++++++++++----- lib/schemaUtils.js | 4 +- lib/schemapack.js | 2 - test/unit/bundle.test.js | 193 +++++++++++++++++++++++++++++++-------- 5 files changed, 224 insertions(+), 66 deletions(-) create mode 100644 bundled.json diff --git a/bundled.json b/bundled.json new file mode 100644 index 0000000..f4ea7e3 --- /dev/null +++ b/bundled.json @@ -0,0 +1 @@ +"{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Sample API\",\"description\":\"Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.\",\"version\":\"0.1.9\"},\"servers\":[{\"url\":\"http://api.example.com/v1\",\"description\":\"Optional server description, e.g. Main (production) server\"},{\"url\":\"http://staging-api.example.com\",\"description\":\"Optional server description, e.g. Internal staging server for testing\"}],\"paths\":{\"/users/{userId}\":{\"get\":{\"summary\":\"Get a user by ID\",\"parameters\":\"...\",\"responses\":{\"200\":{\"description\":\"A single user.\",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/User\"}}}},\"404\":{\"$ref\":\"#/components/responses/NotFound\"}}}},\"/users\":{\"get\":{\"summary\":\"Get all users\",\"responses\":{\"200\":{\"description\":\"A list of users.\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/components/schemas/User\"}}}}}}}}},\"components\":{\"responses\":{\"$ref\":\"./responses.yaml\"},\"schemas\":{\"Monster\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"clientName\":{\"type\":\"string\"}}},\"User\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"userName\":{\"type\":\"string\"}}},\"Toy\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"toyName\":{\"type\":\"string\"}}}}}}" \ No newline at end of file diff --git a/lib/bundle.js b/lib/bundle.js index ca73790..b07ce22 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -46,6 +46,16 @@ function parseFileOrThrow(fileContent) { return result; } +/** + * Parses a node content or throw ParseError if there's any error + * @param {string} fileContent The content from the current node + * @returns {object} The parsed content + */ +function parseFile(fileContent) { + const result = parse.getOasObject(fileContent); + return result; +} + /** * Calculates the path relative to parent * @param {string} parentFileName - parent file name of the current node @@ -270,13 +280,15 @@ function handleLocalCollisions(trace, initialMainKeys) { * @param {object} version - The version of the spec we are bundling * @param {object} rootMainKeys - A dictionary with the component keys in local components object and its mainKeys * @param {string} commonPathFromData - The common path in the file's paths + * @param {Array} allData - array of { path, content} objects * @returns {object} - The references in current node and the new content from the node */ function getReferences (currentNode, isOutOfRoot, pathSolver, parentFilename, version, rootMainKeys, - commonPathFromData) { + commonPathFromData, allData) { let referencesInNode = [], nodeReferenceDirectory = {}, mainKeys = {}; + traverseUtility(currentNode).forEach(function (property) { if (property) { let hasReferenceTypeKey; @@ -307,11 +319,21 @@ function getReferences (currentNode, isOutOfRoot, pathSolver, parentFilename, ve return item !== undefined; }), this.key]; let newValue, - [, local] = tempRef.split(localPointer); + [, local] = tempRef.split(localPointer), + nodeFromData, + refHasContent = false, + parseResult; newValue = Object.assign({}, this.node); - newValue.$ref = referenceInDocument; - + nodeFromData = findNodeFromPath(tempRef, allData); + if (nodeFromData && nodeFromData.content) { + parseResult = parseFile(nodeFromData.content); + if (parseResult.result) { + newValue.$ref = referenceInDocument; + refHasContent = true; + nodeFromData.parsed = parseResult; + } + } this.update({ $ref: tempRef }); nodeReferenceDirectory[tempRef] = { @@ -321,7 +343,8 @@ function getReferences (currentNode, isOutOfRoot, pathSolver, parentFilename, ve reference: referenceInDocument, traceToParent, parentNodeKey: parentFilename, - mainKeyInTrace: nodeTrace[nodeTrace.length - 1] + mainKeyInTrace: nodeTrace[nodeTrace.length - 1], + refHasContent }; mainKeys[componentKey] = tempRef; @@ -349,13 +372,18 @@ function getReferences (currentNode, isOutOfRoot, pathSolver, parentFilename, ve function getNodeContentAndReferences (currentNode, allData, specRoot, version, rootMainKeys, commonPathFromData) { let graphAdj = [], missingNodes = [], - nodeContent; + nodeContent, + parseResult; if (currentNode.parsed) { nodeContent = currentNode.parsed.oasObject; } else { - nodeContent = parseFileOrThrow(currentNode.content).oasObject; + parseResult = parseFile(currentNode.content); + if (parseResult.result === false) { + return { graphAdj, missingNodes, undefined, nodeReferenceDirectory: {}, nodeName: currentNode.fileName }; + } + nodeContent = parseResult.oasObject; } const { referencesInNode, nodeReferenceDirectory } = getReferences( @@ -365,7 +393,8 @@ function getNodeContentAndReferences (currentNode, allData, specRoot, version, r currentNode.fileName, version, rootMainKeys, - commonPathFromData + commonPathFromData, + allData ); referencesInNode.forEach((reference) => { @@ -404,12 +433,14 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver }); notInLine.forEach(([key, value]) => { let [, partial] = key.split(localPointer); - setValueInComponents( - value.keyInComponents, - components, - getContentFromTrace(documentContext.nodeContents[key], partial), - version - ); + if (documentContext.globalReferences[key].refHasContent) { + setValueInComponents( + value.keyInComponents, + components, + getContentFromTrace(documentContext.nodeContents[key], partial), + version + ); + } }); [rootContent, components].forEach((contentData) => { traverseUtility(contentData).forEach(function (property) { @@ -429,12 +460,17 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver return missingNode.path === nodeRef; }); if (isMissingNode) { - refData.nodeContent = { - [tempRef]: 'This related node was not found in provided data' - }; - refData.inline = true; + // refData.nodeContent = { + // [tempRef]: 'This related node was not found in provided data' + // }; + refData.nodeContent = refData.node; + // refData.inline = true; + this.update(refData.node); refData.local = false; } + if (!refData) { + return; + } else { refData.nodeContent = documentContext.nodeContents[nodeRef]; refData.inline = refData.keyInComponents.length === 0; @@ -451,14 +487,18 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver if (refData.inline) { refData.node = refData.nodeContent; } - this.update(refData.node); + if (!isMissingNode) { + this.update(refData.node); + } if (!refData.inline) { - setValueInComponents( - refData.keyInComponents, - components, - refData.nodeContent, - version - ); + if (documentContext.globalReferences[tempRef].refHasContent) { + setValueInComponents( + refData.keyInComponents, + components, + refData.nodeContent, + version + ); + } } } } diff --git a/lib/schemaUtils.js b/lib/schemaUtils.js index 5ad0306..88b34d3 100644 --- a/lib/schemaUtils.js +++ b/lib/schemaUtils.js @@ -4848,7 +4848,9 @@ module.exports = { mapBundleOutput(format, parsedRootFiles) { return (contentAndComponents) => { let bundledFile = contentAndComponents.fileContent; - bundledFile.components = contentAndComponents.components; + if (!_.isEmpty(contentAndComponents.components)) { + bundledFile.components = contentAndComponents.components; + } if (!format) { let rootFormat = parsedRootFiles.find((inputRoot) => { return inputRoot.fileName === contentAndComponents.fileName; diff --git a/lib/schemapack.js b/lib/schemapack.js index 34a26dd..16a12be 100644 --- a/lib/schemapack.js +++ b/lib/schemapack.js @@ -644,11 +644,9 @@ class SchemaPack { path = pathBrowserify; OasResolverOptions.browser = true; } - // if ('content' in input.data[0]) { input.data.forEach((file) => { files[path.resolve(file.fileName)] = file.content ? file.content : ''; }); - // } adaptedInput = schemaUtils.mapDetectRootFilesInputToGetRootFilesInput(input); adaptedInput.origin = input.origin; rootFiles = parse.getRootFiles(adaptedInput, concreteUtils.inputValidation, this.computedOptions, files, diff --git a/test/unit/bundle.test.js b/test/unit/bundle.test.js index 4c40370..9b01247 100644 --- a/test/unit/bundle.test.js +++ b/test/unit/bundle.test.js @@ -703,6 +703,8 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; + fs.writeFileSync('bundled.json', JSON.stringify(res.output.data[0].bundledContent)); + expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); @@ -1938,43 +1940,6 @@ describe('bundle files method - 3.0', function () { }); - it('should ignore reference when is empty content', async function() { - let input = - { - type: 'multiFile', - specificationVersion: '3.0', - bundleFormat: 'JSON', - data: [ - { - path: 'hello.yaml', - content: '' - }, - { - path: 'openapi.yaml', - content: 'openapi: 3.0.0\n' + - 'info:\n' + - ' title: hello world\n' + - ' version: 0.1.1\n' + - 'paths:\n' + - ' /hello:\n' + - ' get:\n' + - ' summary: get the hello\n' + - ' responses:\n' + - ' 200:\n' + - ' description: sample des\n' + - ' content:\n' + - ' application/json:\n' + - ' schema:\n' + - ' $ref: \'./hello.yaml\'' - } - ] - }; - const res = await Converter.bundle(input); - expect(res).to.not.be.empty; - expect(res.result).to.be.true; - expect(res.output.specification.version).to.equal('3.0'); - }); - it('Should return bundled file as json - schema_collision_from_responses', async function () { let contentRootFile = fs.readFileSync(schemaCollision + '/root.yaml', 'utf8'), user = fs.readFileSync(schemaCollision + '/schemas_/_user.yaml', 'utf8'), @@ -2107,6 +2072,157 @@ describe('bundle files method - 3.0', function () { expect(res.output.specification.version).to.equal('3.0'); expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); + + it('should ignore reference when is empty content and no root is sent', async function () { + let input = + { + type: 'multiFile', + specificationVersion: '3.0', + bundleFormat: 'YAML', + data: [ + { + path: 'hello.yaml', + content: '' + }, + { + path: 'openapi.yaml', + content: 'openapi: 3.0.0\n' + + 'info:\n' + + ' title: hello world\n' + + ' version: 0.1.1\n' + + 'paths:\n' + + ' /hello:\n' + + ' get:\n' + + ' summary: get the hello\n' + + ' responses:\n' + + ' \'200\':\n' + + ' description: sample des\n' + + ' content:\n' + + ' application/json:\n' + + ' schema:\n' + + ' $ref: ./hello.yaml\n' + } + ] + }; + const res = await Converter.bundle(input); + expect(res).to.not.be.empty; + expect(res.result).to.be.true; + expect(res.output.specification.version).to.equal('3.0'); + expect(res.output.data[0].bundledContent).to.be.equal(input.data[1].content); + }); + + it('should ignore reference when is empty content', async function () { + let input = + { + type: 'multiFile', + specificationVersion: '3.0', + bundleFormat: 'YAML', + rootFiles: [{ path: 'openapi.yaml' }], + data: [ + { + path: 'hello.yaml', + content: '' + }, + { + path: 'openapi.yaml', + content: 'openapi: 3.0.0\n' + + 'info:\n' + + ' title: hello world\n' + + ' version: 0.1.1\n' + + 'paths:\n' + + ' /hello:\n' + + ' get:\n' + + ' summary: get the hello\n' + + ' responses:\n' + + ' \'200\':\n' + + ' description: sample des\n' + + ' content:\n' + + ' application/json:\n' + + ' schema:\n' + + ' $ref: ./hello.yaml\n' + } + ] + }; + const res = await Converter.bundle(input); + expect(res).to.not.be.empty; + expect(res.result).to.be.true; + expect(res.output.specification.version).to.equal('3.0'); + expect(res.output.data[0].bundledContent).to.be.equal(input.data[1].content); + }); + + it('should ignore reference when is invalid content', async function () { + let input = + { + type: 'multiFile', + specificationVersion: '3.0', + bundleFormat: 'YAML', + rootFiles: [{ path: 'openapi.yaml' }], + data: [ + { + path: 'hello.yaml', + content: 'asd' + }, + { + path: 'openapi.yaml', + content: 'openapi: 3.0.0\n' + + 'info:\n' + + ' title: hello world\n' + + ' version: 0.1.1\n' + + 'paths:\n' + + ' /hello:\n' + + ' get:\n' + + ' summary: get the hello\n' + + ' responses:\n' + + ' \'200\':\n' + + ' description: sample des\n' + + ' content:\n' + + ' application/json:\n' + + ' schema:\n' + + ' $ref: ./hello.yaml\n' + } + ] + }; + const res = await Converter.bundle(input); + expect(res).to.not.be.empty; + expect(res.result).to.be.true; + expect(res.output.specification.version).to.equal('3.0'); + expect(res.output.data[0].bundledContent).to.be.equal(input.data[1].content); + }); + + it('should ignore reference when is invalid', async function () { + let input = + { + type: 'multiFile', + specificationVersion: '3.0', + bundleFormat: 'YAML', + rootFiles: [{ path: 'openapi.yaml' }], + data: [ + { + path: 'openapi.yaml', + content: 'openapi: 3.0.0\n' + + 'info:\n' + + ' title: hello world\n' + + ' version: 0.1.1\n' + + 'paths:\n' + + ' /hello:\n' + + ' get:\n' + + ' summary: get the hello\n' + + ' responses:\n' + + ' \'200\':\n' + + ' description: sample des\n' + + ' content:\n' + + ' application/json:\n' + + ' schema:\n' + + ' $ref: ./hello.yaml\n' + } + ] + }; + const res = await Converter.bundle(input); + expect(res).to.not.be.empty; + expect(res.result).to.be.true; + expect(res.output.specification.version).to.equal('3.0'); + expect(res.output.data[0].bundledContent).to.be.equal(input.data[0].content); + }); }); @@ -2163,7 +2279,8 @@ describe('getReferences method when node does not have any reference', function( 'the/parent/filename', '3.0', {}, - '' + '', + [] ); expect(result.nodeReferenceDirectory).to.be.an('object'); expect(Object.keys(result.nodeReferenceDirectory).length).to.equal(1); From b34397a1d4a5718f83db2968ae370ea62b20e1ec Mon Sep 17 00:00:00 2001 From: Erik Mendoza Date: Wed, 22 Jun 2022 19:13:42 -0500 Subject: [PATCH 3/5] Handling not provided node when is referenced from local components --- lib/bundle.js | 11 ++--------- .../local_references/expectedNodeNotProvided.json | 2 +- test/unit/bundle.test.js | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/bundle.js b/lib/bundle.js index b07ce22..c54297d 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -460,15 +460,10 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver return missingNode.path === nodeRef; }); if (isMissingNode) { - // refData.nodeContent = { - // [tempRef]: 'This related node was not found in provided data' - // }; refData.nodeContent = refData.node; - // refData.inline = true; - this.update(refData.node); refData.local = false; } - if (!refData) { + else if (!refData) { return; } else { @@ -487,9 +482,7 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver if (refData.inline) { refData.node = refData.nodeContent; } - if (!isMissingNode) { - this.update(refData.node); - } + this.update(refData.node); if (!refData.inline) { if (documentContext.globalReferences[tempRef].refHasContent) { setValueInComponents( diff --git a/test/data/toBundleExamples/local_references/expectedNodeNotProvided.json b/test/data/toBundleExamples/local_references/expectedNodeNotProvided.json index 9a8dd9c..5f1c8d1 100644 --- a/test/data/toBundleExamples/local_references/expectedNodeNotProvided.json +++ b/test/data/toBundleExamples/local_references/expectedNodeNotProvided.json @@ -60,7 +60,7 @@ }, "components": { "responses": { - "/responses.yaml": "This related node was not found in provided data" + "$ref": "./responses.yaml" }, "schemas": { "Monster": { diff --git a/test/unit/bundle.test.js b/test/unit/bundle.test.js index 9b01247..fc7041e 100644 --- a/test/unit/bundle.test.js +++ b/test/unit/bundle.test.js @@ -663,8 +663,8 @@ describe('bundle files method - 3.0', function () { expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); }); - it('Should return a "/missing/node/path": NotProvided' + - ' in the place of a not providen node - local_references', async function () { + it('Should return the not handled reference ($ref: ./responses.yaml) ' + + 'in the place of a not provided node - local_references', async function () { let contentRootFile = fs.readFileSync(localRefFolder + '/root.yaml', 'utf8'), schemasIndex = fs.readFileSync(localRefFolder + '/schemas/index.yaml', 'utf8'), schemasClient = fs.readFileSync(localRefFolder + '/schemas/client.yaml', 'utf8'), From 042e7c534684c77463576cb976bcbd50c83c4cca Mon Sep 17 00:00:00 2001 From: Luis Tejeda <46000487+LuisTejedaS@users.noreply.github.com> Date: Thu, 23 Jun 2022 10:55:54 -0500 Subject: [PATCH 4/5] Delete bundled.json --- bundled.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 bundled.json diff --git a/bundled.json b/bundled.json deleted file mode 100644 index f4ea7e3..0000000 --- a/bundled.json +++ /dev/null @@ -1 +0,0 @@ -"{\"openapi\":\"3.0.0\",\"info\":{\"title\":\"Sample API\",\"description\":\"Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.\",\"version\":\"0.1.9\"},\"servers\":[{\"url\":\"http://api.example.com/v1\",\"description\":\"Optional server description, e.g. Main (production) server\"},{\"url\":\"http://staging-api.example.com\",\"description\":\"Optional server description, e.g. Internal staging server for testing\"}],\"paths\":{\"/users/{userId}\":{\"get\":{\"summary\":\"Get a user by ID\",\"parameters\":\"...\",\"responses\":{\"200\":{\"description\":\"A single user.\",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/schemas/User\"}}}},\"404\":{\"$ref\":\"#/components/responses/NotFound\"}}}},\"/users\":{\"get\":{\"summary\":\"Get all users\",\"responses\":{\"200\":{\"description\":\"A list of users.\",\"content\":{\"application/json\":{\"schema\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/components/schemas/User\"}}}}}}}}},\"components\":{\"responses\":{\"$ref\":\"./responses.yaml\"},\"schemas\":{\"Monster\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"clientName\":{\"type\":\"string\"}}},\"User\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"userName\":{\"type\":\"string\"}}},\"Toy\":{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"toyName\":{\"type\":\"string\"}}}}}}" \ No newline at end of file From e48170c63df22d592fa22dc985fc57602a77d8ed Mon Sep 17 00:00:00 2001 From: Luis Tejeda <46000487+LuisTejedaS@users.noreply.github.com> Date: Thu, 23 Jun 2022 11:11:54 -0500 Subject: [PATCH 5/5] Update bundle.test.js --- test/unit/bundle.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/unit/bundle.test.js b/test/unit/bundle.test.js index fc7041e..9341219 100644 --- a/test/unit/bundle.test.js +++ b/test/unit/bundle.test.js @@ -703,8 +703,6 @@ describe('bundle files method - 3.0', function () { expect(res).to.not.be.empty; expect(res.result).to.be.true; - fs.writeFileSync('bundled.json', JSON.stringify(res.output.data[0].bundledContent)); - expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected); });