Skip to content

Command line tool to convert Node-RED function node, Swagger document, or WoT Thing Description to a custom Node.

License

Notifications You must be signed in to change notification settings

node-red/node-red-nodegen

Repository files navigation

NOTICE: This branch (webofthings) is under heavy active development and not fully tested. Not suitable for production.

Node generator for Node-RED

Node generator is command line tool to generate Node-RED node modules from several various sources including Swagger specification and function node's source. Using this tool, node developers can dramatically reduce their time to implement Node-RED node modules.

Installation

Install node generator globally to make the node-red-nodegen command available on your path:

npm install -g node-red-nodegen

You may need to run this with sudo, or from within an Administrator command shell.

Usage

Usage:
   node-red-nodegen <source file or URL> [-o <path to save>] [--prefix <prefix string>] [--name <node name>] [--module <module name>] [--version <version number>] [--tgz] [--help]

Description:
   Node generator for Node-RED

Supported source:
   - Function node (js file in library, "~/.node-red/lib/function/")
   - Swagger definition
   - Thing Description of W3C Web of Things (jsonld file or URL that points jsonld file)

Options:
   -o : Destination path to save generated node (default: current directory)
   --prefix : Prefix of npm module (default: "node-red-contrib-")
   --name : Node name (default: name defined in source)
   --module : Module name (default: "node-red-contrib-<node name>")
   --version : Node version (format: "number.number.number" like "4.5.1")
   --keywords : Additional keywords (format: comma separated string, default: "node-red-nodegen")
   --category : Node category (default: "function")
   --tgz : Save node as tgz file
   --help : Show help
   --wottd : explicitly instruct that source file/URL points a Thing Description
   --lang : Language negotiation information when retrieve a Thing Description

Example 1. Create original node from Swagger definition

-> You can use swagger-petstore node on Node-RED flow editor.

Example 2. Create original node from function node (JavaScript code)

  • On Node-RED flow editor, save function node to library with file name (lower-case.js).
  • node-red-nodegen ~/.node-red/lib/function/lower-case.js
  • cd node-red-contrib-lower-case
  • sudo npm link
  • cd ~/.node-red
  • npm link node-red-contrib-lower-case
  • node-red

-> You can use lower-case node on Node-RED flow editor.

Example 3. Create original node from Thing Description

  • node-red-nodegen example.jsonld
  • cd node-red-contrib-example-thing
  • sudo npm link
  • cd ~/.node-red
  • npm link node-red-contrib-example-thing
  • node-red

-> You can use Example Thing node on Node-RED flow editor.

Example 4. Create original node from Thing Description via HTTP

  • node-red-nodegen http://example.com/td.jsonld --wottd --lang "en-US,en;q=0.5"
  • cd node-red-contrib-example-thing
  • sudo npm link
  • cd ~/.node-red
  • npm link node-red-contrib-example-thing
  • node-red

-> You can use Example Thing node on Node-RED flow editor.

Documentation

Note: Currently node generator supports GET and POST methods using JSON format without authentication.

About

Command line tool to convert Node-RED function node, Swagger document, or WoT Thing Description to a custom Node.

Resources

License

Stars

Watchers

Forks

Packages

No packages published