Node-red-node-swagger and node-red-constrib-http-custom-port

Hi,

I am trying to get node-red-node-swagger to generate swagger documentation. I can get it working for a HTTP IN node but not the node-red-constrib-http-custom-port on a custom port. Any ideas?

    {
        "id": "636df2a183b16ff4",
        "type": "node-red-contrib-http-custom-port",
        "z": "e18f95efaa76815e",
        "name": "",
        "url": "/api/testNotVisible",
        "method": "post",
        "upload": false,
        "swaggerDoc": "6699d3b594113217",
        "port": "8080",
        "x": 590,
        "y": 260,
        "wires": [
            [
                "fb9d66179dae2cfe"
            ]
        ]
    },
    {
        "id": "fb9d66179dae2cfe",
        "type": "http response",
        "z": "e18f95efaa76815e",
        "name": "",
        "statusCode": "200",
        "headers": {
            "status": "ok"
        },
        "x": 1100,
        "y": 260,
        "wires": []
    },
    {
        "id": "bd1ddf843cfa518c",
        "type": "http in",
        "z": "e18f95efaa76815e",
        "name": "",
        "url": "/api/visible",
        "method": "post",
        "upload": false,
        "swaggerDoc": "14749f632af54b53",
        "x": 560,
        "y": 340,
        "wires": [
            [
                "ab504247fdc63bd2"
            ]
        ]
    },
    {
        "id": "ab504247fdc63bd2",
        "type": "http response",
        "z": "e18f95efaa76815e",
        "name": "",
        "statusCode": "200",
        "headers": {
            "status": "ok"
        },
        "x": 1100,
        "y": 340,
        "wires": []
    },
    {
        "id": "6699d3b594113217",
        "type": "swagger-doc",
        "summary": "Not visible",
        "description": "Test API not visible in Swagger",
        "tags": "",
        "consumes": "",
        "produces": "",
        "parameters": [
            {
                "name": "x-api-key",
                "in": "header",
                "description": "the api-key",
                "required": true,
                "type": "string"
            }
        ],
        "responses": {
            "200": {
                "description": "Successful"
            }
        },
        "deprecated": false
    },
    {
        "id": "14749f632af54b53",
        "type": "swagger-doc",
        "summary": "API Visible",
        "description": "API Visible in Swagger",
        "tags": "",
        "consumes": "",
        "produces": "",
        "parameters": [],
        "responses": {},
        "deprecated": false
    }
] ```

You will probably need to ask the author of that node.

There are a couple of other alternatives depending on what you actually want to achieve.

  1. Use a reverse proxy such as NGINX or Caddy to listen on an alternative port but proxy the requests through to Node-RED's port.
  2. Use uibuilder which allows for a different ExpressJS server with control over ExpressJS settings.

Yes, the swagger plug-in is hard-coded to search through your flows for flows that start with an http in node, and terminate with an http response node. The code will not find any other endpoints, nor will it find flows that are connected through link out / link in pairs. It is a limitation that I've thought about fixing in the past, but never actually done.

A better implementation may be to inspect the express endpoints, so contributed nodes could (maybe) be included, but features related to swagger are not used enough to get any development attention -- so they wait for one of us to fix and contribute back.

In that case Steve, my option 1 above would probably be the best work-around.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.