Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
fix: fail when collection don't have ´variable´ parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
joolfe committed Aug 5, 2021
1 parent d48517a commit bb02ad6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/var-replacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Mustache.Writer.prototype.escapedValue = function escapedValue (token, context,

function replacePostmanVariables (collectionString, additionalVars = {}) {
const postmanJson = JSON.parse(collectionString)
const { variable } = postmanJson
const { variable = [] } = postmanJson
const formatVars = variable.reduce((obj, { key, value }) => {
obj[key] = value
return obj
Expand Down
5 changes: 5 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ describe('Library specs', function () {
})
equal(result, EXPECTED_VARIABLES_ADDITIONAL)
})

it('should not fail if no variable are defined and want to replace', async function () {
const result = await postmanToOpenApi(COLLECTION_FORM_DATA, OUTPUT_PATH, { replaceVars: true })
equal(result, EXPECTED_FORM_DATA)
})
})
})

Expand Down

0 comments on commit bb02ad6

Please sign in to comment.