node-red-flowgen 0.0.2

Generate Node-RED flows and function-node code from OpenAPI 3 / Swagger 2 documents

npm install node-red-flowgen

node-red-flowgen

Generate Node-RED flows from OpenAPI 3.x / Swagger 2.0 documents.

Pick an endpoint from an API definition and get a ready-to-run flow — inject, function, http request and debug — where the function node sets up msg for the request: method, URL, headers, cookies and a sample body. It works as an editor plugin that adds an API Spec tab to the Import dialog.

Install

cd ~/.node-red
npm install node-red-flowgen

Or grab node-red-flowgen.tgz from the latest release and npm install ./node-red-flowgen.tgz. Restart Node-RED afterwards. Once installed, the plugin works fully offline — every asset is served by Node-RED itself.

How to use editor plugin

  1. Open Import node dialog by selecting Import item from the menu.

    menu
  2. Select API Spec tab, then paste an API document (JSON or YAML), paste its URL, or upload a file.

    import
  3. One endpoint → Import lights up immediately. Several → press Select endpoint >, pick one from the Swagger-UI-style list (arrow keys work), then Import.

    endpoints
  4. The four nodes are added to the current flow.

    flow

Generated code for function node

msg.method = 'GET';
msg.url = 'http://petstore.swagger.io/v2/pet/findByStatus?status=available';
// msg.url = 'http://petstore.swagger.io/v2/pet/findByStatus?status=pending';
// msg.url = 'http://petstore.swagger.io/v2/pet/findByStatus?status=sold';

// Fill in 'authorization' below.
msg.headers = {
  'authorization': 'Bearer ',
  'accept': 'application/json'
};
return msg;
  • Parameter values are filled from the spec (enum, example, default). The first candidate goes into msg.url; alternatives follow as commented-out lines, so Ctrl + / toggles between them.
  • Anything the spec leaves open gets a comment saying what to edit, with the type when known: // Replace {petId} (integer) in the URL below with a real value.
  • Authentication comes from the security definitions: API keys in header/query/cookie, Bearer / basic prefixes in authorization.
  • multipart/form-data bodies use the http request node's file-upload shape ({ value: FILE_CONTENTS, options: { filename: FILENAME } }).

Node Info

Version: 0.0.2
Updated 11 hours ago
License: Apache-2.0
Rating: not yet rated

Categories

Actions

Rate:

Downloads

0 in the last week

Keywords

  • node-red
  • openapi
  • swagger

Maintainers