mlabouardy / swaggymnia

Generate Swagger 🌀 documentation for your existing API in Insomnia
MIT License
426 stars 31 forks source link

New Insomnia (v4) format causes app to crash #14

Open EnilPajic opened 5 years ago

EnilPajic commented 5 years ago

Expected behavior

To generate a swagger.json file.

Current behavior

Application crashes with stacktrace:

./swaggymnia generate -insomnia httpbin.json -c config.json -o json
panic: assignment to entry in nil map

goroutine 1 [running]:
main.parse(0xc420012af0, 0x6, 0x4, 0xed4622342, 0x27290640, 0x0, 0xc42000ac40, 0x1b, 0xc420084580, 0x4, ...)
    C:/Users/Mohamed/go/src/github.com/mlabouardy/swaggymnia/swagger.go:51 +0x32c
main.(*Swagger).Generate(0xc4200d37d8, 0x7ffeefbffaa8, 0xc, 0x7ffeefbffab8, 0xb, 0x7ffeefbffac7, 0x4)
    C:/Users/Mohamed/go/src/github.com/mlabouardy/swaggymnia/swagger.go:83 +0x11f
main.main.func1(0xc420080840, 0x10100, 0xc420080840)
    C:/Users/Mohamed/go/src/github.com/mlabouardy/swaggymnia/app.go:57 +0x180
github.com/urfave/cli.HandleAction(0x11bd260, 0x12080d8, 0xc420080840, 0xc42006a300, 0x0)
    C:/Users/Mohamed/go/src/github.com/urfave/cli/app.go:502 +0xd4
github.com/urfave/cli.Command.Run(0x11fab4d, 0x8, 0x0, 0x0, 0xc420012880, 0x1, 0x1, 0x1202246, 0x1e, 0x0, ...)
    C:/Users/Mohamed/go/src/github.com/urfave/cli/command.go:210 +0xb87
github.com/urfave/cli.(*App).Run(0xc4200c01c0, 0xc42000e080, 0x8, 0x8, 0x0, 0x0)
    C:/Users/Mohamed/go/src/github.com/urfave/cli/app.go:259 +0x7b7
main.main()
    C:/Users/Mohamed/go/src/github.com/mlabouardy/swaggymnia/app.go:66 +0x515

config.json is simple:

{
  "title" : "REST",
  "version" : "0.0.0-rest",
  "host" : "test.server.com",
  "basePath" : "/api/",
  "schemes" : "HTTP protocol",
  "description" : "API test"
}

And my httpbin.json is exported from Insomnia (for testing purpose, only one request is used, request is curl -X GET "https://httpbin.org/get" -H "accept: application/json"):

{
  "_type": "export",
  "__export_format": 4,
  "__export_date": "2019-05-06T12:44:50.657Z",
  "__export_source": "insomnia.desktop.app:v6.4.1",
  "resources": [
    {
      "_id": "req_cd668ad743b84a53a3f7484ffe285abe",
      "authentication": {},
      "body": {},
      "created": 1557146662559,
      "description": "",
      "headers": [
        {
          "name": "accept",
          "value": "application/json"
        }
      ],
      "isPrivate": false,
      "metaSortKey": -1557146662559,
      "method": "GET",
      "modified": 1557146664393,
      "name": "HttpBin",
      "parameters": [],
      "parentId": "wrk_7766cf26944f4d9d84e2183cfb9496cc",
      "settingDisableRenderRequestBody": false,
      "settingEncodeUrl": true,
      "settingMaxTimelineDataSize": 1000,
      "settingRebuildPath": true,
      "settingSendCookies": true,
      "settingStoreCookies": true,
      "url": "https://httpbin.org/get",
      "_type": "request"
    },
    {
      "_id": "wrk_7766cf26944f4d9d84e2183cfb9496cc",
      "created": 1557146654014,
      "description": "",
      "modified": 1557146654014,
      "name": "Test.HttpBin",
      "parentId": null,
      "_type": "workspace"
    },
    {
      "_id": "env_c65ad3eac00c7c67c9618d12ac830147f9913d21",
      "color": null,
      "created": 1557146654327,
      "data": {},
      "isPrivate": false,
      "metaSortKey": 1557146654327,
      "modified": 1557146654327,
      "name": "Base Environment",
      "parentId": "wrk_7766cf26944f4d9d84e2183cfb9496cc",
      "_type": "environment"
    },
    {
      "_id": "jar_c65ad3eac00c7c67c9618d12ac830147f9913d21",
      "cookies": [],
      "created": 1557146654334,
      "modified": 1557146654334,
      "name": "Default Jar",
      "parentId": "wrk_7766cf26944f4d9d84e2183cfb9496cc",
      "_type": "cookie_jar"
    }
  ]
}

I'm using Insomnia 6.4.1 (6.4.1.2725) for Mac (Mojave).

./swaggymnia --version
swaggymnia version 1.0.0-beta

Before Insomnia update, everything worked fine, but now Insomnia offers to export to

and that (new) v4 format is not compatible with swaggymnia anymore?

Steps to reproduce the behavior

Thank you in advance!

mazz commented 5 years ago

The maintainer does not seem responsive. Anybody know of an alternative way to convert insomnia json to swagger?

kkashyap1707 commented 5 years ago

Still facing the issue. Do we have any work around or any previous version by which our work will not hamper?

Fyb3roptik commented 5 years ago

Please check this ticket. I have updated the code and pushed a new version:

https://github.com/mlabouardy/swaggymnia/issues/8#issuecomment-482171647

Fyb3roptik commented 5 years ago

I will be creating a new repo for this since I have emailed him several times and gotten no response. I will assume its abandoned and will take it over

kkashyap1707 commented 5 years ago

Thanks in advance. Waiting for your new repository.

On Thu, 30 May 2019, 21:36 Nick Wallace, notifications@github.com wrote:

I will be creating a new repo for this since I have emailed him several times and gotten no response. I will assume its abandoned and will take it over

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mlabouardy/swaggymnia/issues/14?email_source=notifications&email_token=ABD7FBFBYFDGF4PKDCN3F4TPX73PTA5CNFSM4HK7YSZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWSX4TA#issuecomment-497385036, or mute the thread https://github.com/notifications/unsubscribe-auth/ABD7FBCABEXCMOPDQ4OE6ILPX73PTANCNFSM4HK7YSZA .

Fyb3roptik commented 5 years ago

https://github.com/Fyb3roptik/swaggomnia

HeathNaylor commented 5 years ago

Ahh, the beauty of open source. Your fork works great.