question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when importing Swagger 2.0 json file

See original GitHub issue

Describe the bug When trying to import a Swagger 2.0 json file, I get the following error:

The file does not contain a valid specification.

StackTrace

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be one of type string, Buffer, TypedArray, or DataView. Received type undefined
    at Hash.update (internal/crypto/hash.js:70:11)
    at importFolderItem (/Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/insomnia-importers/src/importers/swagger2.js:161:6)
    at /Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/insomnia-importers/src/importers/swagger2.js:129:12
    at Array.map (<anonymous>)
    at parseEndpoints (/Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/insomnia-importers/src/importers/swagger2.js:128:46)
    at Object.module.exports.convert (/Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/insomnia-importers/src/importers/swagger2.js:68:21)
    at async module.exports.convert (/Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/insomnia-importers/index.js:19:23)
    at async importRaw (file:///Applications/Insomnia.app/Contents/Resources/app.asar/bundle.js:42846:15)
    at async Object.importUri (file:///Applications/Insomnia.app/Contents/Resources/app.asar/bundle.js:42808:18)
    at async file:///Applications/Insomnia.app/Contents/Resources/app.asar/bundle.js:79047:24

Expected behavior File should import without issues.

Desktop (please complete the following information):

  • OS: MacOS 10.15.7
  • App Version: 2020.4.1

Additional context

  • The Swagger Editor does find several warnings, but no errors, so the file should parse.
  • The file is in JSON format, not YAML.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
avevladcommented, Dec 19, 2020

Workaround:

  1. open http://editor.swagger.io/
  2. paste existing swagger2 test -input file
  3. (transform JSON->YAML when asked, if necessary)
  4. Edit > Convert to OpenAPI 3
  5. export (as JSON or YAML, depending on existing test)
0reactions
jcebcommented, Dec 16, 2021

Same here, the error got solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Encounter error when import swagger json to create multiple ...
Hi guys,. I want to consume a REST API which created by Mule, but when i added multiple methods by importing the swagger...
Read more >
Cannot import swagger 2.0 file anymore (it was working ...
Hello, I'm trying to import a swagger (yaml or json) file generate ... 2 ~ Failed to import Swagger 2.0”,“Error importing Swagger 2.0...
Read more >
Error while Importing - json swagger file - Oracle Communities
When trying to import the swagger file in web tools, we got below error. I did check for the error and could find...
Read more >
Cannot import swagger 2.0 JSON file into smartdocs model
You should have a `swagger` directive in your openapi spec, not "openapi", that could be the problem. Another option is to convert to...
Read more >
Could not import" error while importing NSX-T API Spec into ...
"Error while importing Swagger 2.0: Could not import" error while importing NSX-T API Spec into Postman (74984) ... This issue occurs due to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found