Skip to content

Generate a Datapower Multi Protocol Gateway with basic configuration to proxy Rest API service using Swagger file.

Notifications You must be signed in to change notification settings

guyHollander/GenerateMpgwFromSwagger

Repository files navigation

GenerateMpgwFromSwagger

GenerateMpgwFromSwagger (GMFS) is a simple, node base tool, that create a basic DP's Multi protocol Gateway configuration exposing a remote REST service according to his Swagger file.

currently, the mpgw service that created to expose the remote REST service has the following configuration:

  • a generic HTTP/HTTPS front side handler (listener).
  • Processing policy contains a pair of processing rules for each Resource path on the remote REST service.

Installation

GMFS is using Datapower's Rest Managment Interface to configurate the target machine and Swagger-parser Node js Model to Parse the swagger file. So, first of all, you'll have to install Node js on your local computer (windows installation guide, linux installation guide ). then, you'll need to enable the Rest Managment API on your datapower target machine.

After completeing those prerequisites, Clone the project folder into your local computer with git clone command or download and extract the project folder.

Running The Tool

  1. Copy the swagger file into the project directory.
  2. Configure the tool. the configuration file, config.json, composed from swagger file property, and 2 Objects. Please make sure that the configuration is valid before running the tool!
{
  "swaggerFileName":"Swagger file name",
  "restMngIntConfig":
    {
      "host": "Datapower Rest mng int listener address",
      "port":"Datapower Rest mng int listener address",
      "auth": "user:password"
    },
    "mpgwConfig": {
      "name":"mpgw name. if empty generate name from swagger file",
      "domain":"Datapower's domain where mpgw will be created",
      "localHost":"Datapower local machine addrees used by the service",
      "localPort":"Datapower local Port used by service",
      "sslFrontSideHandler": false for http Front side handler true for https,
      "sslObjectType":"if true choose type of ssl object - server, sni, proxy",
      "sslObjectName":"name of ssl object"
    }
}
  1. From GMFS project folder run the following command:
node GenerateMpgwFromSwagger.js
  1. If successfully created MPGW, be aware of:
  • The order of the rules is the same as the order of paths in swagger file. some order changes might be necessary.
  • Paths containing $ref definitions like int or string won't be resolved automatically in this version. you have to replace those manually in swagger file before you run the tool, or in DP matching rules afterwards with fitting regex expression .
  1. If for some reason the tool failed to create MPGW, you'll have to remove manually any DP's object the tool has managed to create, or just use what already created and create the rest by yourself.

About

Generate a Datapower Multi Protocol Gateway with basic configuration to proxy Rest API service using Swagger file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published