codeasashu / insomnia-oas-converter

Insomnia file to openapi converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert Method Fails - Always Returns Null

derringa opened this issue · comments

Summary

I've exported multiple collections as JSON but the convert method always fails and returns null.

Environment

  • Platform: Windows 10 version 1909
  • Insomnia: v2021.4.1
  • Node: 12.18.1 (also tried 12.22.1 via nvm)
  • insomnia-oas-converter: 1.0.2

Current Behavior

The SchemaConverter combines the insomnia export and OpenAPI config nicely but the example script fails at

let spec = schema.convert();
// spec = null

Insomnia Export Example

{
  "_type": "export",
  "__export_format": 4,
  "__export_date": "2021-07-14T19:51:51.736Z",
  "__export_source": "insomnia.desktop.app:v2021.4.1",
  "resources": [
    {
      "_id": "req_0aeb8573659a492ab4028726e03a1696",
      "parentId": "fld_9801f91f2f9e4537a12a73f953f1deee",
      "modified": 1626287396908,
      "created": 1626287357111,
      "url": "https://decepticons.rule.com/goodbye/world",
      "name": "world",
      "description": "",
      "method": "GET",
      "body": {
        "mimeType": "multipart/form-data",
        "params": [
          {
            "id": "pair_6b664b7a8d2a451eabeb11e15b4f8769",
            "name": "name",
            "value": "Megatron",
            "description": ""
          },
          {
            "id": "pair_0315d148eba343408ad76277b1108bfb",
            "name": "age",
            "value": "21",
            "description": ""
          }
        ]
      },
      "parameters": [],
      "headers": [
        {
          "name": "Content-Type",
          "value": "multipart/form-data",
          "id": "pair_262c30b58f014fac873a9ade3dabfc17"
        }
      ],
      "authentication": {},
      "metaSortKey": -1626287357111,
      "isPrivate": false,
      "settingStoreCookies": true,
      "settingSendCookies": true,
      "settingDisableRenderRequestBody": false,
      "settingEncodeUrl": true,
      "settingRebuildPath": true,
      "settingFollowRedirects": "global",
      "_type": "request"
    },
    {
      "_id": "fld_9801f91f2f9e4537a12a73f953f1deee",
      "parentId": "wrk_aac7134f6f2d48438d027978bd6064d0",
      "modified": 1626287353256,
      "created": 1626287353256,
      "name": "goodbye",
      "description": "",
      "environment": {},
      "environmentPropertyOrder": null,
      "metaSortKey": -1626287353256,
      "_type": "request_group"
    },
    {
      "_id": "wrk_aac7134f6f2d48438d027978bd6064d0",
      "parentId": null,
      "modified": 1626287344161,
      "created": 1626287344161,
      "name": "test",
      "description": "",
      "scope": "collection",
      "_type": "workspace"
    },
    {
      "_id": "env_57227cd827cc9c7ea3d58f94345b578b4e8e8792",
      "parentId": "wrk_aac7134f6f2d48438d027978bd6064d0",
      "modified": 1626287344579,
      "created": 1626287344579,
      "name": "Base Environment",
      "data": {},
      "dataPropertyOrder": null,
      "color": null,
      "isPrivate": false,
      "metaSortKey": 1626287344579,
      "_type": "environment"
    },
    {
      "_id": "jar_57227cd827cc9c7ea3d58f94345b578b4e8e8792",
      "parentId": "wrk_aac7134f6f2d48438d027978bd6064d0",
      "modified": 1626287344586,
      "created": 1626287344586,
      "name": "Default Jar",
      "cookies": [],
      "_type": "cookie_jar"
    },
    {
      "_id": "spc_d7f2d07af61044d5a78167fc5d039199",
      "parentId": "wrk_aac7134f6f2d48438d027978bd6064d0",
      "modified": 1626287344164,
      "created": 1626287344164,
      "fileName": "test",
      "contents": "",
      "contentType": "yaml",
      "_type": "api_spec"
    }
  ]
}

Hello @derringa Can you try the branch fix-example? It should fix the issue

Hey @codeasashu the simple example with the one request works as expected, but there are another scenarios that breaks, I will provide an example to help to fix it.

Hey @codeasashu looking into this scenario, seems look that the error happens when there is folder created to organize the requests.

Hey @fadonascimento the folder example works for me. Can you try to create a sample minimal insomnia collection for me try?