converter.SchemaPack throw a following exception "Cannot read property 'filter' of undefined"
sabat24 opened this issue · comments
I get the Insomnia workspace data directly from Insomnia and save it into insomniaExportedInput
variable. Structure seems to be correct:
{
"_type": "export",
"__export_format": 4,
"__export_date": "2021-07-16T09:29:02.038Z",
"__export_source": "insomnia.desktop.app:v2021.3.0",
"resources": [
{
"_id": "req_5f839e7c7da64eb7a3a3810bc3279272",
"parentId": "fld_104805e78d3a4f8ab237bc492c225952",
"modified": 1624541741810,
"created": 1611153938298,
"url": "{{host}}/auth/login",
"name": "Login",
"description": "",
"method": "POST",
"body": {
"mimeType": "application/json",
"text": "{\n\t\t\"email\": \"@\",\n \"password\": \"\"\n}"
},
"parameters": [
{
}
],
"headers": [
{
"name": "Content-Type",
"value": "application/json",
"id": "pair_33c2131a152641adb9d115f00d5991f4"
}
],
"authentication": {},
"metaSortKey": -1611157553722,
"isPrivate": false,
"settingStoreCookies": true,
"settingSendCookies": true,
"settingDisableRenderRequestBody": false,
"settingEncodeUrl": true,
"settingRebuildPath": true,
"settingFollowRedirects": "global",
"_type": "request"
}
]
}
I pasted only one resource just as an example.
Then trying to run that command let schema = new converter.SchemaPack(insomniaExportedInput, openapiConfig)
I receive following exception:
@sabat24 It seems to me that the parameter exported looks bit fuzzy.
"parameters": [
{
}
],
Just curious, what does it represent? In the UI terms, does it mean you tried to add a parameter and emptied it (and not deleted)?
@sabat24 Can you also give fix-example branch a try? It seems working with the schema you provided.
In parameters
section there was some simple key: value
object provided. I removed the body here to not obfuscate the whole resource object. I'll do a check that branch on Monday. Then I can attach also my whole workspace here which is assigned to insomniaExportedInput
variable (2.8MB) with whole source code of my plugin.
@sabat24 can you paste the complete stacktrace here?
It was my fault. That method
await context.data.export.insomnia({
includePrivate: false,
format: 'json',
workspace: models.workspace,
});
returns string
formatted as JSON not a JSON object per se. When I dumped the result of that method I received a JSON object, because my tools converted that response to the JSON object in the fly.