From 061b0facc1010280a879481aa51d9c9b639c5c37 Mon Sep 17 00:00:00 2001 From: NektariosFifes <61620751+NektariosFifes@users.noreply.github.com> Date: Wed, 8 Mar 2023 13:25:05 +0200 Subject: [PATCH] fix: fixed relative basepath cli option bug (#160) fixes #45 --- src/bin/cli.js | 2 +- src/parser/index.js | 4 ++-- src/parser/parseFiles.js | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bin/cli.js b/src/bin/cli.js index dffdf2794..5f6629a3a 100755 --- a/src/bin/cli.js +++ b/src/bin/cli.js @@ -119,7 +119,7 @@ const verifyInputGetData = async (rd, asyncApiFilepath,scenarioFile,basedir) => scenarioFile = await inputLoopScenario(rd,scenarioFile,yamlJsonRegex,basedir); - const dataFromParser = await parserAndGenerator(asyncApiFilepath,scenarioFile); + const dataFromParser = await parserAndGenerator(asyncApiFilepath,scenarioFile,basedir); const availableServers = Object.keys(dataFromParser.servers); diff --git a/src/parser/index.js b/src/parser/index.js index 06c83a4ab..512c24548 100644 --- a/src/parser/index.js +++ b/src/parser/index.js @@ -13,8 +13,8 @@ function getParameterDefinitions(channels) { return paramDefinitions; } -const parserAndGenerator = async (asyncApiFilepath,scenarioFilepath) => { - const [asyncApiContent,scenarioContent] = await parseFiles(asyncApiFilepath,scenarioFilepath); +const parserAndGenerator = async (asyncApiFilepath,scenarioFilepath,basedir) => { + const [asyncApiContent,scenarioContent] = await parseFiles(asyncApiFilepath,scenarioFilepath,basedir); const operationsData = { servers: asyncApiContent._json.servers, parameterDefinitions: {}, diff --git a/src/parser/parseFiles.js b/src/parser/parseFiles.js index 6f4511c09..f9f0b50ef 100644 --- a/src/parser/parseFiles.js +++ b/src/parser/parseFiles.js @@ -9,7 +9,7 @@ const yamlParser = require('js-yaml'); * @param filepathScenario * @returns {Promise<(*|*|string|Chai.Assertion)[]>} */ -const parseFiles = async (filepathAsyncApi, filepathScenario) => { +const parseFiles = async (filepathAsyncApi, filepathScenario,basedir) => { const ajv = new Ajv({allowMatchingProperties: true,strict: true,allErrors: true, verbose: true}); let asyncApiContent; try { @@ -18,8 +18,7 @@ const parseFiles = async (filepathAsyncApi, filepathScenario) => { } catch (err) { console.log(`\nError in reading the asyncApi file. Details: ${err}`); } - const asyncApiParsed = await parser.parse(asyncApiContent); - + const asyncApiParsed = await parser.parse(asyncApiContent, {path: basedir}); let scenarioParsed; try { // eslint-disable-next-line security/detect-non-literal-fs-filename