Throws 'Cannot read property nullable of undefined'
tbowmo opened this issue · 5 comments
Trying to run a very minimalist setup, using the pet store example on swagger.io:
{
"url": "https://petstore.swagger.io/v2/swagger.json",
"dir": "./test",
"language": "typescript",
"ignore": {}
}
When running swagger-typescript, I get the following error:
yarn run v1.22.5
$ node ./node_modules/swagger-typescript/lib/index.js
{
error: TypeError: Cannot read property 'nullable' of undefined
at /home/thomas/react/inviteanerd/node_modules/swagger-typescript/lib/utils.js:135:57
at Array.every (<anonymous>)
at Object.getParametersInfo (/home/thomas/react/inviteanerd/node_modules/swagger-typescript/lib/utils.js:135:28)
at /home/thomas/react/inviteanerd/node_modules/swagger-typescript/lib/generator.js:25:117
at Array.forEach (<anonymous>)
at /home/thomas/react/inviteanerd/node_modules/swagger-typescript/lib/generator.js:12:35
at Array.forEach (<anonymous>)
at Object.generator (/home/thomas/react/inviteanerd/node_modules/swagger-typescript/lib/generator.js:11:37)
at generate (/home/thomas/react/inviteanerd/node_modules/swagger-typescript/lib/index.js:20:34)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
}
Version info:
typescript 3.7,
node 14.13,
yarn 1.22.5
Hi there,
As mentioned in the README Swagger-Typescript just working with OpenApi v3, it seems your configured JSON is not OpenApi v3.
If you are interested in testing it, use this JSON: https://generator3.swagger.io/openapi.json
Right, I had used my own semi-handcrafted json file (generated with swagger-php from phpdoc annotations). It was missing the components/schema (as I hadn't created any schemas yet), and so it fails.
Perhaps a basic validation of the entire file, or some better error messages, when something goes wrong would be good.. Otherwise you are shooting in the dark, when trying to figure out what is wrong.
(Feel free to close this, if you want to.. could be considered as a reminder for future features)
Right, I had used my own semi-handcrafted json file (generated with swagger-php from phpdoc annotations). It was missing the components/schema (as I hadn't created any schemas yet), and so it fails.
Perhaps a basic validation of the entire file, or some better error messages, when something goes wrong would be good.. Otherwise you are shooting in the dark, when trying to figure out what is wrong.
(Feel free to close this, if you want to.. could be considered as a reminder for future features)
Thank you.
I will do it soon.