5

I'm trying to import a Json file from Swagger to insomnia. To do that I use this project from NPM (I'm not familiar with NPM):

https://www.npmjs.com/package/insomnia-importers

I have npm v6.5.0 and node v11.9.0 installed.

I ran this command: `insomnia-import /path/to/swagger-export.json

insomnia-export.json:

 (node:38053) UnhandledPromiseRejectionWarning: TypeError: Cannot
 convert undefined or null to object
     at Function.keys (<anonymous>)
     at object (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:300:14)
     at generateParameterExample (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:332:12)
     at Object.keys.forEach.propertyName (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:301:33)
     at Array.forEach (<anonymous>)
     at object (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:300:31)
     at generateParameterExample (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:332:12)
     at prepareBody (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:242:37)
     at importRequest (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:173:11)
     at tags.forEach (/Users/user/.nvm/versions/node/v11.9.0/lib/node_modules/insomnia-importers/src/importers/swagger2.js:129:21)
 (node:38053) UnhandledPromiseRejectionWarning: Unhandled promise
 rejection. This error originated either by throwing inside of an async
 function without a catch block, or by rejecting a promise which was
 not handled with .catch(). (rejection id: 1) (node:38053) [DEP0018]
 DeprecationWarning: Unhandled promise rejections are deprecated. In
 the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.

What is the problem here?

A-Tech
  • 806
  • 6
  • 22
AleGallagher
  • 1,745
  • 7
  • 30
  • 40

1 Answers1

10

Insomnia maintainer here.

Insomnia uses the insomnia-import package internally so you don't have to. You can import your Swagger file directly into Insomnia and it will import it.

gschier
  • 326
  • 3
  • 5
  • Is it possible to export insomnia json in a way swagger can read it? – Enrique Feb 15 '21 at 11:27
  • 1
    Would it be possible to add a description how this can be done/ link to it? – ntg May 25 '22 at 09:35
  • https://docs.insomnia.rest/insomnia/import-export-data#import-data note that if the interface is password protected, you might have to save the .json file and provide it instead of just using the url directly... – ntg May 25 '22 at 10:52