Skip to content

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

@shrickus

Description

@shrickus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions