mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Folder for multifile and multi data res
Change the use of folder and now use multiFile as option type value. Return a JS object instead of a json string return a data array in response
This commit is contained in:
@@ -167,7 +167,7 @@ function getSpecVersion({ type, data, specificationVersion }) {
|
||||
return DEFAULT_SPEC_VERSION;
|
||||
}
|
||||
|
||||
if (['folder'].includes(type)) {
|
||||
if (['folder', 'multiFile'].includes(type)) {
|
||||
data = getFileWithVersion(data, specificationVersion);
|
||||
}
|
||||
else if (['file'].includes(type)) {
|
||||
|
||||
@@ -4854,15 +4854,17 @@ module.exports = {
|
||||
let bundleData = getBundleContentAndComponents(root, inputData, origin);
|
||||
return bundleData;
|
||||
});
|
||||
let bundledFile = data[0].fileContent;
|
||||
bundledFile.components = data[0].components;
|
||||
if (format === parse.YAML_FORMAT) {
|
||||
bundledFile = parse.toYAML(bundledFile);
|
||||
}
|
||||
else if (format === parse.JSON_FORMAT) {
|
||||
bundledFile = parse.toJSON(bundledFile, 2);
|
||||
}
|
||||
return { rootFile: { path: parsedRootFiles[0].fileName }, bundledContent: bundledFile };
|
||||
|
||||
let bundleData = data.map((contentAndComponents) => {
|
||||
let bundledFile = contentAndComponents.fileContent;
|
||||
bundledFile.components = contentAndComponents.components;
|
||||
if (format === parse.YAML_FORMAT) {
|
||||
bundledFile = parse.toYAML(bundledFile);
|
||||
}
|
||||
return { rootFile: { path: parsedRootFiles[0].fileName }, bundledContent: bundledFile };
|
||||
});
|
||||
|
||||
return bundleData;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,11 +31,10 @@ const COLLECTION_NAME = 'Imported from OpenAPI 3.0',
|
||||
let path = require('path'),
|
||||
concreteUtils,
|
||||
pathBrowserify = require('path-browserify');
|
||||
// traverseUtility = require('traverse');
|
||||
|
||||
class SchemaPack {
|
||||
constructor (input, options = {}) {
|
||||
if (input.type === 'folder' && input.data && input.data[0] && input.data[0].path) {
|
||||
if (input.type === 'multiFile' && input.data && input.data[0] && input.data[0].path) {
|
||||
input = schemaUtils.mapDetectRootFilesInputToFolderInput(input);
|
||||
}
|
||||
this.input = input;
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('bundle files method - 3.0', function () {
|
||||
user = fs.readFileSync(schemaFromResponse + '/schemas/user.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(schemaFromResponse + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -51,7 +51,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file as yaml - schema_from_response', async function () {
|
||||
@@ -59,7 +59,7 @@ describe('bundle files method - 3.0', function () {
|
||||
user = fs.readFileSync(schemaFromResponse + '/schemas/user.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(schemaFromResponse + '/expected.yaml', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -79,7 +79,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(res.output.data[0].bundledContent).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file in same format than root file - schema_from_response', async function () {
|
||||
@@ -87,7 +87,7 @@ describe('bundle files method - 3.0', function () {
|
||||
user = fs.readFileSync(schemaFromResponse + '/schemas/user.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(schemaFromResponse + '/expected.yaml', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -106,7 +106,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(res.output.data[0].bundledContent).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - nested_references_from_root_components', async function () {
|
||||
@@ -119,7 +119,7 @@ describe('bundle files method - 3.0', function () {
|
||||
userProps = fs.readFileSync(nestedRefsFromRootComponents + '/userProps.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(nestedRefsFromRootComponents + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -159,7 +159,8 @@ 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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
|
||||
});
|
||||
|
||||
it('Should return bundled file - local_references', async function () {
|
||||
@@ -170,7 +171,7 @@ describe('bundle files method - 3.0', function () {
|
||||
toySchema = fs.readFileSync(localRefFolder + '/otherSchemas/toy.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(localRefFolder + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -202,7 +203,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - petstore separated example', async function () {
|
||||
@@ -225,7 +226,7 @@ describe('bundle files method - 3.0', function () {
|
||||
errorCommon = fs.readFileSync(petstoreFolder + '/common/Error.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(petstoreFolder + '/bundleExp.yaml', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -305,7 +306,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(res.output.data[0].bundledContent).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - with_parameters', async function () {
|
||||
@@ -314,7 +315,7 @@ describe('bundle files method - 3.0', function () {
|
||||
parameters = fs.readFileSync(withParamsFolder + '/parameters/index.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(withParamsFolder + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -338,7 +339,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - with_ref_in_items', async function () {
|
||||
@@ -347,7 +348,7 @@ describe('bundle files method - 3.0', function () {
|
||||
superProp = fs.readFileSync(withRefInItems + '/schemas/superProp.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(withRefInItems + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -371,8 +372,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(res.output.data.bundledContent)
|
||||
.to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return error data - with_ref_in_items - wrong root', async function () {
|
||||
@@ -380,7 +380,7 @@ describe('bundle files method - 3.0', function () {
|
||||
user = fs.readFileSync(withRefInItems + '/schemas/user.yaml', 'utf8'),
|
||||
superProp = fs.readFileSync(withRefInItems + '/schemas/superProp.yaml', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -420,7 +420,7 @@ describe('bundle files method - 3.0', function () {
|
||||
magic = fs.readFileSync(sameRefDiffSource + '/schemas/client/magic.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(sameRefDiffSource + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -456,7 +456,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file - multiple_references_from_root_components', async function () {
|
||||
@@ -472,7 +472,7 @@ describe('bundle files method - 3.0', function () {
|
||||
othersWork = fs.readFileSync(nestedHard + '/otherSchemas/work.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(nestedHard + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -524,7 +524,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(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 () {
|
||||
@@ -532,7 +532,7 @@ describe('bundle files method - 3.0', function () {
|
||||
user = fs.readFileSync(localFromExternal + '/schemas/user.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(localFromExternal + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -552,7 +552,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(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 () {
|
||||
@@ -561,7 +561,7 @@ describe('bundle files method - 3.0', function () {
|
||||
food = fs.readFileSync(localFromExternalMultiple + '/schemas/food.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(localFromExternalMultiple + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -585,7 +585,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return a "/missing/node/path": NotProvided' +
|
||||
@@ -596,7 +596,7 @@ describe('bundle files method - 3.0', function () {
|
||||
toySchema = fs.readFileSync(localRefFolder + '/otherSchemas/toy.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(localRefFolder + '/expectedNodeNotProvided.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -624,7 +624,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file with referenced tags from root', async function () {
|
||||
@@ -632,7 +632,7 @@ describe('bundle files method - 3.0', function () {
|
||||
tags = fs.readFileSync(refTags + '/tags/tags.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(refTags + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -652,7 +652,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file with referenced info from root', async function () {
|
||||
@@ -660,7 +660,7 @@ describe('bundle files method - 3.0', function () {
|
||||
info = fs.readFileSync(refInfo + '/info/info.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(refInfo + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -680,7 +680,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should return bundled file with referenced paths from root', async function () {
|
||||
@@ -689,7 +689,7 @@ describe('bundle files method - 3.0', function () {
|
||||
path = fs.readFileSync(refPaths + '/paths/path.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(refPaths + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -713,7 +713,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(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 () {
|
||||
@@ -722,7 +722,7 @@ describe('bundle files method - 3.0', function () {
|
||||
path = fs.readFileSync(refPathsRefToLocalSchema + '/paths/path.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(refPathsRefToLocalSchema + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -746,7 +746,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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should take the root file from data array', async function () {
|
||||
@@ -758,7 +758,7 @@ describe('bundle files method - 3.0', function () {
|
||||
magic = fs.readFileSync(sameRefDiffSource + '/schemas/client/magic.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(sameRefDiffSource + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
data: [
|
||||
{
|
||||
@@ -792,14 +792,13 @@ 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(res.output.data.bundledContent).to.be.equal(expected);
|
||||
|
||||
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('Should throw error when input has not root files', async function () {
|
||||
let user = fs.readFileSync(schemaFromResponse + '/schemas/user.yaml', 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [],
|
||||
data: [
|
||||
@@ -818,6 +817,61 @@ describe('bundle files method - 3.0', function () {
|
||||
expect(error.message).to.equal('Input should have at least one root file');
|
||||
}
|
||||
});
|
||||
|
||||
it('Should return bundled files with 2 root', async function () {
|
||||
let contentRootFile = fs.readFileSync(schemaFromResponse + '/root.yaml', 'utf8'),
|
||||
user = fs.readFileSync(schemaFromResponse + '/schemas/user.yaml', 'utf8'),
|
||||
expected = fs.readFileSync(schemaFromResponse + '/expected.json', 'utf8'),
|
||||
contentRootFile2 = fs.readFileSync(localRefFolder + '/root.yaml', 'utf8'),
|
||||
responses = fs.readFileSync(localRefFolder + '/responses.yaml', 'utf8'),
|
||||
schemasIndex = fs.readFileSync(localRefFolder + '/schemas/index.yaml', 'utf8'),
|
||||
schemasClient = fs.readFileSync(localRefFolder + '/schemas/client.yaml', 'utf8'),
|
||||
toySchema = fs.readFileSync(localRefFolder + '/otherSchemas/toy.yaml', 'utf8'),
|
||||
expected2 = fs.readFileSync(localRefFolder + '/expected.json', 'utf8'),
|
||||
input = {
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/root.yaml',
|
||||
content: contentRootFile
|
||||
},
|
||||
{
|
||||
path: '/root2.yaml',
|
||||
content: contentRootFile2
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
path: '/schemas/user.yaml',
|
||||
content: user
|
||||
},
|
||||
{
|
||||
path: '/responses.yaml',
|
||||
content: responses
|
||||
},
|
||||
{
|
||||
path: '/schemas/index.yaml',
|
||||
content: schemasIndex
|
||||
},
|
||||
{
|
||||
path: '/schemas/client.yaml',
|
||||
content: schemasClient
|
||||
},
|
||||
{
|
||||
path: '/otherSchemas/toy.yaml',
|
||||
content: toySchema
|
||||
}
|
||||
],
|
||||
options: {},
|
||||
bundleFormat: 'JSON'
|
||||
};
|
||||
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(res.output.data[1].bundledContent, null, 2)).to.be.equal(expected2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -917,7 +971,7 @@ describe('getReferences method when node does not have any reference', function(
|
||||
|
||||
it('should return error when input data is an empty array', async function () {
|
||||
try {
|
||||
await Converter.bundle({ type: 'folder', data: [] });
|
||||
await Converter.bundle({ type: 'multiFile', data: [] });
|
||||
}
|
||||
catch (error) {
|
||||
expect(error).to.not.be.undefined;
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('detectRelatedFiles method', function () {
|
||||
it('should return error when there is no root in the entry', async function () {
|
||||
let contentFile = fs.readFileSync(petstoreSeparatedPet, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
],
|
||||
@@ -55,7 +55,7 @@ describe('detectRelatedFiles method', function () {
|
||||
it('should locate root and return empty data when there is no ref', async function () {
|
||||
let contentFile = fs.readFileSync(validPetstore, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
],
|
||||
@@ -78,7 +78,7 @@ describe('detectRelatedFiles method', function () {
|
||||
const contentFileMissedRef = fs.readFileSync(missedRef, 'utf8'),
|
||||
contentFilePet = fs.readFileSync(petstoreSeparatedPet, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -106,7 +106,7 @@ describe('detectRelatedFiles method', function () {
|
||||
const contentFilRefToRoot = fs.readFileSync(refToRoot, 'utf8'),
|
||||
contentFilePet = fs.readFileSync(circularRefNewPet, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -133,7 +133,7 @@ describe('detectRelatedFiles method', function () {
|
||||
it('should not return local ref as missing node', async function () {
|
||||
const contentFileMissedRef = fs.readFileSync(internalRefOnly, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -157,7 +157,7 @@ describe('detectRelatedFiles method', function () {
|
||||
contentFileOldPet = fs.readFileSync(oldPet, 'utf8'),
|
||||
contentFilePet = fs.readFileSync(pet, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -193,7 +193,7 @@ describe('detectRelatedFiles method', function () {
|
||||
newPetContent = fs.readFileSync(newPet, 'utf8'),
|
||||
errorContent = fs.readFileSync(petstoreSeparatedError, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -231,7 +231,7 @@ describe('detectRelatedFiles method', function () {
|
||||
let contentFilePet = fs.readFileSync(validPetstore, 'utf8'),
|
||||
contentFileHop = fs.readFileSync(validHopService31x, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.1',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -255,7 +255,7 @@ describe('detectRelatedFiles method', function () {
|
||||
let contentFilePet = fs.readFileSync(validPetstore, 'utf8'),
|
||||
contentFileHop = fs.readFileSync(validHopService31x, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
rootFiles: [
|
||||
{
|
||||
path: '/petstore.yaml',
|
||||
@@ -277,7 +277,7 @@ describe('detectRelatedFiles method', function () {
|
||||
it('should return 5 missing related files', async function () {
|
||||
let contentFile = fs.readFileSync(petstoreMultipleFiles, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -298,7 +298,7 @@ describe('detectRelatedFiles method', function () {
|
||||
let contentRootFile = fs.readFileSync(petstoreMultipleFiles, 'utf8'),
|
||||
contentFileResPets = fs.readFileSync(resourcesPets, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -328,7 +328,7 @@ describe('detectRelatedFiles method', function () {
|
||||
contentFileSchemaIndex = fs.readFileSync(schemaIndex, 'utf8'),
|
||||
contentFileResponseIndex = fs.readFileSync(responseIndex, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
rootFiles: [
|
||||
{
|
||||
@@ -405,7 +405,7 @@ describe('detectRelatedFiles method', function () {
|
||||
|
||||
it('should return error when input data is an empty array', async function () {
|
||||
try {
|
||||
await Converter.detectRelatedFiles({ type: 'folder', data: [] });
|
||||
await Converter.detectRelatedFiles({ type: 'multiFile', data: [] });
|
||||
}
|
||||
catch (error) {
|
||||
expect(error).to.not.be.undefined;
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('detectRoot method', function() {
|
||||
it('should return one root 3.0 correctly no specific version', async function() {
|
||||
let contentFile = fs.readFileSync(validPetstore, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
data: [
|
||||
{
|
||||
path: '/petstore.yaml',
|
||||
@@ -38,7 +38,7 @@ describe('detectRoot method', function() {
|
||||
it('should return one root 3.0 correctly', async function() {
|
||||
let contentFile = fs.readFileSync(validPetstore, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
data: [
|
||||
{
|
||||
@@ -56,7 +56,7 @@ describe('detectRoot method', function() {
|
||||
it('should return no root when specific version is not present', async function() {
|
||||
let contentFile = fs.readFileSync(validPetstore, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.1',
|
||||
data: [
|
||||
{
|
||||
@@ -75,7 +75,7 @@ describe('detectRoot method', function() {
|
||||
let petRoot = fs.readFileSync(petstoreSeparated, 'utf8'),
|
||||
petSchema = fs.readFileSync(petstoreSeparatedPet, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
data: [
|
||||
{
|
||||
@@ -98,7 +98,7 @@ describe('detectRoot method', function() {
|
||||
it('should return one root 3.1 correctly', async function() {
|
||||
let contentFile = fs.readFileSync(validHopService31x, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.1',
|
||||
data: [
|
||||
{
|
||||
@@ -117,7 +117,7 @@ describe('detectRoot method', function() {
|
||||
let petstoreContent = fs.readFileSync(validPetstore, 'utf8'),
|
||||
hopService31x = fs.readFileSync(validHopService31x, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0.0',
|
||||
data: [
|
||||
{
|
||||
@@ -141,7 +141,7 @@ describe('detectRoot method', function() {
|
||||
let petstoreContent = fs.readFileSync(validPetstore, 'utf8'),
|
||||
hopService31x = fs.readFileSync(validHopService31x, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.1.0',
|
||||
data: [
|
||||
{
|
||||
@@ -163,7 +163,7 @@ describe('detectRoot method', function() {
|
||||
|
||||
it('should return no root file when there is not a root file present', async function() {
|
||||
let input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0.0',
|
||||
data: [
|
||||
{
|
||||
@@ -182,7 +182,7 @@ describe('detectRoot method', function() {
|
||||
let petstoreContent = fs.readFileSync(validPetstore, 'utf8'),
|
||||
noAuthContent = fs.readFileSync(noauth, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0.0',
|
||||
data: [
|
||||
{
|
||||
@@ -205,7 +205,7 @@ describe('detectRoot method', function() {
|
||||
|
||||
it('should propagate one error correctly', async function () {
|
||||
let input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0.0',
|
||||
data: [
|
||||
{
|
||||
@@ -226,7 +226,7 @@ describe('detectRoot method', function() {
|
||||
let petRoot = fs.readFileSync(petstoreSeparatedJson, 'utf8'),
|
||||
petSchema = fs.readFileSync(petstoreSeparatedPetJson, 'utf8'),
|
||||
input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.0',
|
||||
data: [
|
||||
{
|
||||
@@ -248,7 +248,7 @@ describe('detectRoot method', function() {
|
||||
|
||||
it('should read content when is not present 3.0 and no specific version', async function () {
|
||||
let input = {
|
||||
type: 'folder',
|
||||
type: 'multiFile',
|
||||
specificationVersion: '3.1.0',
|
||||
data: [
|
||||
{
|
||||
@@ -299,7 +299,7 @@ describe('detectRoot method', function() {
|
||||
|
||||
it('should return error when input data is an empty array', async function () {
|
||||
try {
|
||||
await Converter.detectRootFiles({ type: 'folder', data: [] });
|
||||
await Converter.detectRootFiles({ type: 'multiFile', data: [] });
|
||||
}
|
||||
catch (error) {
|
||||
expect(error).to.not.be.undefined;
|
||||
|
||||
Reference in New Issue
Block a user