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

Error on scrapeURL #136

Description

@KillianLeroux

Hi!

I tried to execute library with the latest version (1.16.0) and I have this error:

TypeError [ERR_INVALID_URL]: Invalid URL: {{base_url}}/companies/:companyId
    at onParseError (internal/url.js:279:9)
    at new URL (internal/url.js:355:5)
    at scrapeURL (C:\Users\kikit\Desktop\LamacomptaApiDoc\bin\p2o_original\node_modules\postman-to-openapi\lib\index.js:358:18)
    at postmanToOpenApi (C:\Users\kikit\Desktop\LamacomptaApiDoc\bin\p2o_original\node_modules\postman-to-openapi\lib\index.js:40:58) {
  input: '{{base_url}}/companies/:companyId',
  code: 'ERR_INVALID_URL'
}

Apparently it's because variables don't replaced ( here: {{base_url}} ).

It's just a note, I know it's already planned to add this feature ;)

My function "setVars" provided here: #131 (comment)
could be useful:

/**
 * Populate variables in provided string
 *
 * @param {string} string    String to process
 * @param {array}  variables Array of variables for replacements
 *
 * @returns {string} String with variables populated
 */
function setVars(string, variables) {
  if (~string.search(/{{\s*[\w\s-]+\s*}}/g)) {
    const varKey = string.replace(/[{*|}*]/g, '').trim()

    return getVarValue(variables, varKey)
  }

  return string
}

Kisses :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions