Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: base directory option bug #160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
5 changes: 2 additions & 3 deletions src/parser/parseFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down