Kong / Kong/insomnia

Error when importing Swagger 2.0 json file

Open
#2,780 10 comments 10 reactions 0 assignees View on GitHub
needs-triage
Dominant language
TypeScript
Stars
40k
Forks
2.4k
Avg merge
2d 13h
Merged PRs (30d)
61

Description

**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 ()
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.

Contributor guide

Open the contributing guide

Research direction

Start with insomnia-importers/src/importers/swagger2.js, especially parseEndpoints and importFolderItem from the reported stack trace. Reproduce the import using a Swagger 2.0 JSON file and inspect the failing input. Done means the reported file imports successfully without the ERR_INVALID_ARG_TYPE error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.