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 48 forks source link

Doesn't seem to work with named parameters (ie /user/:name) #54

Open natcl opened 7 years ago

natcl commented 7 years ago

When adding an endpoint with a parameter, something like /user/:name it doesn't seem to be picked up by the doc.

shrickus commented 7 years ago

Nat, I was seeing something similar, but now it seems to be working fine. I think the confusing thing for me was the order of operations: when I added /:type to the end of my url path and switched to the Parameters tab, the new param did not show up right away. Once I saved the node (and maybe deployed?), then when I re-opened the node config, and selected Docs -> Edit, the new param was shown. Is this what you are seeing as well?

What I'm trying to figure out now (using your url example) is how to use the same http in node to handle both the /user and /user/nat urls -- effectively specifying that the :name param is optional. From what I've read, it looks like that is not supported directly by express (the server would need both urls added to its path list). Of course, I could just copy the http in node and change the url, but it would be nice if that was not necessary. I'm wondering if the node-red swagger node could be enhanced to provide both url paths to the express server, perhaps using some optional syntax like /users/:name? -- or at least an "Optional?" checkbox on the param itself.