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

"List Operations" in sidebar does not include flows with embedded link out/in pairs #59

Open
shrickus opened this issue Apr 24, 2018 · 1 comment

Comments

@shrickus
Copy link

I tracked down why my new http endpoint was not showing in the Swagger sidebar... the code searches from the http in node until it finds a connected http response node -- and if it doesn't find one, it won't show in the Operation List.

This check is good -- however, in my case, the http response node IS connected, but through a link out/in pair, which is causing my api to be excluded from the Operations list. The function that does this validation is:

    function checkWiresForHttpResponse (node) {
        var wires = node.wires[0];
        for(var i in wires){
            var newNode = RED.nodes.getNode(wires[i]);
            if(newNode.type == "http response"){
                return true;
            } else if(checkWiresForHttpResponse(newNode)){
                return true;
            }
        }
        return false;
    }

I tried to "hop over" the link nodes, by checking if node.type === "link out", then use the node.links array (instead of wires[0]). Although node.links exists in the flows.json file, once it is loaded into the runtime, that attribute is no longer available... (?) hmmm

So it probably requires an intermediate node lookup, something like this (untested)?

            var newNode = RED.nodes.getNode(wires[i]);
            if (newNode.type == "link out") {
                newNode = RED.nodes.getNode(node.links[0]);
            }

However, this assumes there is only one link in connected to each link out -- so some iteration will probably be needed. And will this work for wires connected to subflows? Probably not, which makes me wonder if this validation is even necessary.

Today, any http in node wired to an http response node will appear in the list of Swagger Operations. Instead, I suggest we eliminate the checkWires validation, and only include those http in nodes that have a swagger-doc node defined. I'd be happy to submit a PR with these and any other necessary changes, if you agree with my assessment.

@shrickus
Copy link
Author

shrickus commented May 5, 2018

Another broken condition related to this issue -- the node-link traversal seems to only follow wires from the 1st output port of a switch node (and probably other nodes with multiple output ports?).

While developing most of my http "endpoint" flows, I use inject nodes as an alternate way to test the logic of the flow. So at the end of the flow is a switch node that checks if msg.req is not null, and sends the response to an http response node (or a debug node, if not initiated from an http in node). If I test for null first (connected to the debug node) then my endpoint does not show up in the swagger sidebar -- even though there is an http response node at the end of the flow.

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

1 participant