1.1.2 • Published 6 years ago

connector-builder v1.1.2

Weekly downloads
18
License
-
Repository
-
Last release
6 years ago

Connector Builder

This is a CLI tool that generates API-First Connectors based on a provided API definition. An API-First Connector is an SDK that exposes a set of functions for communication with a third party API.

Table of Contents

How To Install?

Prerequisites

Both the CLI and generated project have dependencies that require Node 8.9.1 or higher, together with NPM 5 or higher.

Installation

  • Install connector-builder globally
npm i connector-builder -g

NOTE: if you have any issue due to the installation process, you can use sudo command. It is needed in case of installing npm modules in default folders that need permission. You may need to fill your administrator password. Please find additional information on the following link sudo

As a result you should have connector-builder command in your terminal.

How to update the CLI

If you're using old CLI version, you need to uninstall connector-builder package and to install it globally again:

npm uninstall -g connector-builder
npm install -g connector-builder

How to generate a connector

To list the available options run:

connector-builder h

Using the interactive wizard

connector-builder i

Will start a step by step wizard for filling the necessary information for connector generation.

Wizard steps

  • Provide the name of the connector you want to generate - the naming convention is to use a api-builder-plugin- prefix in lowercase letters e.g. api-builder-plugin-connectorname
  • Provide the URL or the path (absolute or relative) to the API definition - e.g. /Users/Documents/swagger.json
  • Select the Connector Type - there are two given options Cloud Elements or Open API.
  • Select the Context - there are two given options API Builder or Plain JS. Selecting the first one means that the connector is going to be used within API Builder and the second one means that the connector is going to be used in plain javascript application.
  • Enter the absolute path to the location where the connector will be generated (leave empty for current dir) - by default the connector will be generated in your current directory in its own folder otherwise you could specify the location where the connector must be generated.
  • Do you want to remove previous connector if it is already exist - there are two options Y/N

After the above steps you will have successfully generated connector.

Manual usage

Available is a second approach for the generation of a new connector. You need to set all required parameters and connector type. Please find the examples below.

Mandatory parameters

name - the connector name

api - path or URL to the API definition

Optional parameters

type - defines the specifics of API definition and how the connector talks to the underlying service. Please find available connector types below.

context - defines where the connector will be used - API Builder application or Plain JavaScript program. Default choice is API Builder application.

dest - the absolute path to the directory where the connector will be generated

Available Connector types

openapi - generates connector based on Open API Definitions and standard HTTP communication mechanism

Examples of the generation options

Valid flag values:

  • --name - the connector name. Cannot be an empty string, space or cannot have unallowed special characters except ., -, _.
  • --api - url or path to the swagger definition file (absolute or relative)
  • --type - describe the type of the service connector. Two available options: ce (Cloud Elements connector) or openapi (Open API Definitions)

Generation options:

  • standard generation with no overwrite in the current directory:
connector-builder --name [Connector Name] --api [Path or URL to the API Definition] --type [Connector Type]
  • standard generation with overwrite in the current directory:
connector-builder --name [Connector Name] --api [Path or URL to the API Definition] --type [Connector Type] --force
  • generation with default connector type with no overwrite in the current directory:
connector-builder --name [Connector Name] --api [Path or URL of the API Definition]
  • generation with default connector type with overwrite in the current directory:
connector-builder --name [Connector Name] --api [Path or URL of the API Definition] --force
  • generation with default connector type with no overwrite in specified directory:
connector-builder --name [Connector Name] --api [Path or URL of the API Definition] --dest [Absolute Path]

How to refresh the Connector?

If you need to generate the connector again due to changes or if there are more recent versions of your API, please update the content of config/swagger.json file and you can regenerate it via the refresh functionality. You won't lose any test data from your Test Suite. Please follow the steps below:

  • navigate to the root directory of the connector
  • execute the refresh command
connector-builder refresh

As a result, you should have successfully regenerated connector

Supported API definitions

Currently supported standards are:

The files describing the RESTful API in accordance with the Swagger specification are represented as JSON objects and conform to the JSON standards

Author

Axway R&D support@axway.com https://axway.com

License

This code is closed source and Confidential and Proprietary to Axway, Inc. All Rights Reserved. This code MUST not be modified, copied or otherwise redistributed without express written permission of Axway. This file is licensed as part of the Axway Platform and governed under the terms of the Axway license agreement. Your right to use this software terminates when you terminate your Axway subscription.