node-red / node-red-node-swagger

A set of tools for generating Swagger api documentation based on the HTTP nodes deployed in a flow
Apache License 2.0
62 stars 46 forks source link

Swagger UI not displayed #51

Open oprince opened 7 years ago

oprince commented 7 years ago

When loading Node-red UI in chrome, following exception is printed in browser console:

Uncaught TypeError: Cannot read property 'type' of undefined at Object. (swagger-ui.js:254) at Object.10 (swagger-ui.js:778) at Object.f [as inverse] (handlebars-2.0.0.js:27) at Object. (handlebars-2.0.0.js:27) at Object.9 (swagger-ui.js:773) at Object.f [as inverse] (handlebars-2.0.0.js:27) at Object. (handlebars-2.0.0.js:27) at Object.main (swagger-ui.js:789) at e (handlebars-2.0.0.js:27) at s.render (swagger-ui.js:26072)

knolleary commented 7 years ago

Hi - what versions of node.js / node-red / node-red-node-swagger ui are you using?

You've been using the swagger node for some time. Is this the first time you've tried it on Chrome?

oprince commented 7 years ago

Hi,

The versions I use are Node.js: 4.4.7 node-red: 0.14.6 node-red-node-swagger: 0.1.8

I have another project running on the same environment (with Chrome), for which Swagger-UI is displayed correctly.

Seems to be a problem in flows file. I have found an error in method swagger.checkWiresForHttpResponse . There was a case were the wired node was null, causing exception at line

if(newNode.type == "http response")

So, I tried deleting the flow which is leading to that error, but it did not help much. Can I send you the flows file by mail ?

oprince commented 7 years ago

The problem was solved in swagger-ui module file: swagger-ui.js method: Handlebars.registerHelper replace the following line: var paramType = param.type || param.schema && param.schema.type || ''; with the fixed line: var paramType = (param.schema) ? param.type || param.schema.type || '' : param.type || '';

knolleary commented 7 years ago

Please do share the flow file.

Is it one you've manually generated somehow? Does it involve subflows?

... ok, I see you've just closed this having manually fixed something... Does that mean there's nothing for us to do? Does this fix need applying somewhere?

oprince commented 7 years ago

I have created pull request in swagger-ui repository: https://github.com/swagger-api/swagger-ui/pull/2607

The flow was edited only with node-red editor. Yes, it contains subflows. Sending by mail.

knolleary commented 7 years ago

Ok, so we better leave this open so we pick up the fixed swagger-ui when it gets resolved.

JonSilver commented 4 years ago

Alas this one won't get resolved this way because the swagger-ui PR submitted by @oprince was rejected due to the changes being made to the dist folder not the source.