node-red-nodegen
node-red-nodegen copied to clipboard
Fail to generate nodes from Swagger v2 API json file
What are the steps to reproduce?
What happens?
During the attempt to generate the nodes from the swagger.json (v2 format) the parser seems to crash for some reason.
I have checked on https://validator.swagger.io/ using the post request to verify the json validation and could get a green label.
> node-red-nodegen swagger.json
(node:72646) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error: TypeError: Cannot read properties of undefined (reading 'definitions')
TypeError: Cannot read properties of undefined (reading 'definitions')
at /usr/local/lib/node_modules/node-red-nodegen/node_modules/swagger-js-codegen-formdata/lib/typescript.js:48:43
at arrayEach (/usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:530:11)
at Function.forEach (/usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:9410:14)
at convertType (/usr/local/lib/node_modules/node-red-nodegen/node_modules/swagger-js-codegen-formdata/lib/typescript.js:44:19)
at /usr/local/lib/node_modules/node-red-nodegen/node_modules/swagger-js-codegen-formdata/lib/typescript.js:62:32
at /usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:4967:15
at baseForOwn (/usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:3032:24)
at /usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:4936:18
at Function.forEach (/usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:9410:14)
at Object.convertType (/usr/local/lib/node_modules/node-red-nodegen/node_modules/swagger-js-codegen-formdata/lib/typescript.js:61:15)
at /usr/local/lib/node_modules/node-red-nodegen/node_modules/swagger-js-codegen-formdata/lib/codegen.js:184:24
at /usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:4967:15
at baseForOwn (/usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:3032:24)
at /usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:4936:18
at Function.forEach (/usr/local/lib/node_modules/node-red-nodegen/node_modules/lodash/lodash.js:9410:14)
at getViewForSwagger2 (/usr/local/lib/node_modules/node-red-nodegen/node_modules/swagger-js-codegen-formdata/lib/codegen.js:180:7)
What do you expect to happen?
Having the node-generator parse the Swagger V2 file properly and/or give more information about the potential issue during the parsing.
Please tell us about your environment:
- [x] Node generator version: 0.2.4
- [x] Node-RED version: N.A.
- [x] Node.js version: v23.4.0
- [x] npm version: 10.9.2
- [x] Platform/OS: MacOS Sequoia
- [x] Browser: N.A.