mxp100 / insomnia-plugin-openapi-export

Insomnia export to OpenAPI / Swagger
MIT License
7 stars 2 forks source link

error when exporting #3

Closed jorgebrunal closed 9 months ago

jorgebrunal commented 1 year ago

thank you very much for your plugin!

Describe the bug generates errors when exporting a collection with many requests and folders

To Reproduce I have the following:

Expected behavior that the openapi file can be generated 😄

Screenshots 1.

2.

Desktop (please complete the following information):

Additional context it is possible (I am not sure) as seen in the screenshots above, that it is possible that some request are called the same, it would have something to do with the error that is generated when exporting?

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /Users/brunaldo/Library/Application Support/Insomnia/plugins/insomnia-plugin-openapi-export/main.js:141:51
    at Array.forEach (<anonymous>)
    at OpenApiExport.getPaths (/Users/brunaldo/Library/Application Support/Insomnia/plugins/insomnia-plugin-openapi-export/main.js:109:18)
    at action (/Users/brunaldo/Library/Application Support/Insomnia/plugins/insomnia-plugin-openapi-export/main.js:303:31)
    at async file:///Applications/Insomnia.app/Contents/Resources/app.asar/index.9c113364.js:696:65571

again, thank you very much! sorry for the bad translation, I don't speak English.

sthales commented 11 months ago

I have the same problem

mxp100 commented 11 months ago

thank you for reporting, i review this problem and please attach you insomnia json file for reproduce. inside, the function of insomnia itself is used to export first to the json and there was a problem, of course I will try to fix it. P.S. The problem was that if you specify the content type json and at the same time leave the request body empty (not valid), then the internal export will work with errors.

mxp100 commented 11 months ago

trouble with this code

 const insomniaExport = await this.context.data.export.insomnia({
            includePrivate: false,
            format: 'json',
            workspace: this.models.workspace,
});

it some situations, exported invalid json string

help me and create new issue on https://github.com/Kong/insomnia/issues

shide1989 commented 11 months ago

same problem here, did you open an issue yet on https://github.com/Kong/insomnia/issues ?

mxp100 commented 11 months ago

same problem here, did you open an issue yet on https://github.com/Kong/insomnia/issues ?

no free time :(, please report about this problem

mxp100 commented 11 months ago

attach json collection with troubles and add code with trouble

mxp100 commented 9 months ago

released in 2.1.1