Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i tried to use node-red-nodegen is failing with OpenAPI defintions with error messages #124

Open
lauri-aloauri opened this issue Jun 4, 2021 · 1 comment

Comments

@lauri-aloauri
Copy link

Hello !

i tried to use node-red-nodegen with OpenAPI defintions but got error messages,
I would be very plased is some could give reason of these errors and offer some workarouds

My environment :
Node generator version: 0.1.1
Node-RED version: v1.3.5
Node.js version: v14.17.0
npm version: 6.14.13
Platform/OS: Ubuntu 20.04
Browser: FireFox Version 89.0 (64-bit)
I want use node-red-nodegen with OpenAPI description :
https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml
I used also https://editor.swagger.io/ to conert yaml to json format,
Then i tried to use node-red-nodegen with this OpenAPI defintions i got flollowing errors

node-red-nodegen openapi.json --name 'xroad-management-ui'
Error: TypeError: Cannot read property 'definitions' of undefined
TypeError: Cannot read property 'definitions' of undefined
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)

Then i tried the yaml format file
then then at firist the following output was displayed:

Error: Error: ENAMETOOLONG: name too long, open '---

after that the content on yaml and at end the following lines was displyed:

'
at Object.openSync (fs.js:498:3)
at Object.readFileSync (fs.js:394:35)
at Function.Utils.getStringFromFile (/usr/local/lib/node_modules/node-red-nodegen/node_modules/yamljs/lib/Utils.js:284:19)
at Function.Yaml.parseFile (/usr/local/lib/node_modules/node-red-nodegen/node_modules/yamljs/lib/Yaml.js:46:21)
at Function.Yaml.load (/usr/local/lib/node_modules/node-red-nodegen/node_modules/yamljs/lib/Yaml.js:78:17)
at getSpec (/usr/local/lib/node_modules/node-red-nodegen/lib/swagger/index.js:27:27)
at Object.module.exports [as SwaggerNodeGenerator] (/usr/local/lib/node_modules/node-red-nodegen/lib/swagger/index.js:51:16)

@dceejay
Copy link
Member

dceejay commented Jun 4, 2021

I think you need to convert openapi spec v3 to v2 first - see - https://github.com/node-red/node-red-nodegen/wiki#openapi-specification-30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants