Skip to content

Commit

Permalink
Support for WSO2 APIM 3.2.0 and more.. (#32)
Browse files Browse the repository at this point in the history
New Features ✨:
- You will now be able to deploy and manage your API definitions on WSO2 API Manager 3.2.0!!
- It can auto-detect underlying WSO2 API Manager version (2.6.0 or 3.2.0) and magically deploys your API definitions.
- Fully backward-compatible Serverless configurations, for all supported WSO2 API Manager versions.

For Contributors 🙌:
- Added contribution guidelines.
- Added E2E regression tests that you can run locally on your computer (all you need is docker).
  • Loading branch information
ramgrandhi authored Mar 20, 2021
1 parent d52873e commit a9b4724
Show file tree
Hide file tree
Showing 31 changed files with 2,721 additions and 639 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"process": "readonly"
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2017
},
Expand Down
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Thank you for considering to contribute.

<a href="https://github.com/ramgrandhi/serverless-wso2-apim/fork">![x](./assets/fork-me-on-github.png)</a>

# Let's get going..
Just follow these simple steps.

1. `Fork` the repository by clicking the link above.
2. Create a `feature` branch and start building your feature.
3. Regression test your changes locally to ensure that existing functionality has not been broken.
a. Run docker image of **WSO2 API Manager 2.6.0**.

> `docker run -it --name api-manager-260 -p 127.0.0.1:8260:8243 -p 127.0.0.1:9260:9443 --rm wso2/wso2am:2.6.0`
b. Run docker image of **WSO2 API Manager 3.2.0**.

> `docker run -it --name api-manager-320 -p 127.0.0.1:8320:8243 -p 127.0.0.1:9320:9443 --rm wso2/wso2am:3.2.0`
c. Start regression tests.

> `yarn e2e:test`
4. Now, do not forget to add tests related to the feature you just built by creating folders under `src/__tests__/e2e/*` (follow the naming). Run `yarn e2e:test` again.

5. If all tests are passing, you're ready to create a `merge request` into `develop` branch of main repository. _Voila!_ 🚀

59 changes: 39 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
serverless-wso2-apim
====================
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<p>
<a href="https://www.serverless.com">
<img src="http://public.serverless.com/badges/v3.svg">
</a>
<a href="https://www.npmjs.com/package/serverless-wso2-apim">
<img src="https://img.shields.io/npm/v/serverless-wso2-apim?style=flat-square">
</a>
<a href="https://www.npmjs.com/package/serverless-wso2-apim">
<img src="https://img.shields.io/npm/dm/serverless-wso2-apim.svg?style=flat-square">
</a>
<a href="https://www.npmjs.com/package/serverless-wso2-apim">
<img src="http://hits.dwyl.com/ramgrandhi/serverless-wso2-apim.svg">
</a>
<a href="https://opensource.org/licenses/MIT">
<img src="https://img.shields.io/npm/l/serverless-wso2-apim.svg?style=flat-square">
</a>
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square">
</p>


Serverless Framework plugin to manage APIs on [WSO2 API Manager](https://wso2.com/api-management/).

Expand All @@ -10,13 +29,15 @@ Serverless Framework plugin to manage APIs on [WSO2 API Manager](https://wso2.co
## Compatible with
* serverlessˆ1.75
* [WSO2 API Manager 2.6.0](https://docs.wso2.com/display/AM260/)
* [WSO2 API Manager 3.2.0](https://apim.docs.wso2.com/en/3.2.0/) <img src="https://img.shields.io/badge/-New-yellow?style=flat-square">

## Features
* Create, Update and Publish your API definitions via `sls deploy`.
* Manage your API definitions via `sls info` and `sls remove`.
* Supports HTTP and JMS backends with mediation policies & additional API properties.
* Uploads backend certificates (including CAs) to enable HTTP/s connectivity with backends.
* Supports Swagger 2.0 and OpenAPI 3.0 specifications.
* Manage your API definitions via `sls info` and `sls remove`.
* Supports `HTTP` and `JMS` backends with mediation policies & additional API properties.
* Uploads backend certificates (including CAs) to enable HTTP/s connectivity with backends.
* Supports `Swagger 2.0` and `OpenAPI 3.0` specifications.
* Automatically detects the version of WSO2 API Manager running. <img src="https://img.shields.io/badge/-New-yellow?style=flat-square">
---

## Install Plugin
Expand All @@ -43,7 +64,6 @@ or
enabled: false
host: 'wso2-apimanager.com'
port: 443
versionSlug: 'v0.14'
user: 'user@tenant'
pass: 'pass'
gatewayEnv: 'Production'
Expand Down Expand Up @@ -92,36 +112,35 @@ or
> ### **`custom.wso2apim.*`**
| Parameter | What? | Usage Example |
| :------------- |:------------- | ---------------:|
| `enabled` | Default is `true`. <br> when set to `false` explicitly, deployment of APIs on WSO2 will be skipped. Suitable for offline testing etc. | `true`|
| `enabled` | Default is `true`. <br> When set to `false` explicitly, deployment of APIs on WSO2 will be skipped. Suitable for offline testing etc. | `true`|
| `host` | WSO2 API Manager Hostname | `wso2-apimanager.com` |
| `port` | WSO2 API Manager Port | `443` |
| `versionSlug` | WSO2 API Manager's management API version | `v0.14` |
| `user` | Username with an optional tenant symbol | `user@tenant` |
| `pass` | Password, <br> supports [Serverless Variables](https://www.serverless.com/framework/docs/providers/aws/guide/variables/) syntax | `xxx` |
| `gatewayEnv` | Target gateway environment, as configured in your WSO2 installation | `Production` |
| `user` | Username with an optional tenant symbol. | `user@tenant` |
| `pass` | Password, supports [Serverless Variables](https://www.serverless.com/framework/docs/providers/aws/guide/variables/) syntax.| `xxx` |
| `gatewayEnv` | Target gateway environment, as configured in your WSO2 installation. | `Production` |

<br>

> ### **`custom.wso2apim.apidefs.<Your-API>.*`**
| Parameter | What? | Usage Example |
|:------------- |:-------------| ---------------:|
| `name` | (CANNOT BE UPDATED LATER) <br> Your API Name | `MyAwesomeAPI` |
| `version` | (CANNOT BE UPDATED LATER) <br> Your API Version, which also forms a part of the API URL ultimately | `v1` |
| `version` | (CANNOT BE UPDATED LATER) <br> Your API Version, which also forms a part of the API URL ultimately. | `v1` |
| `rootContext` | (CANNOT BE UPDATED LATER) <br> Your API Context, which will be exposed by WSO2 API Gateway. Must be unique per Gateway Environment. | `/myawesomeapi` |
| `description` | Free-form text | `My Awesome API` |
| `visibility` | Currently supports only `PUBLIC`. Accessible from Public Internet, Visible to everyone | `PUBLIC` |
| `visibility` | Supports `PUBLIC` (Visible to everyone) and `PRIVATE` (Visible to current tenant) | `PUBLIC` |
| `backend` | Supports `http` and `jms` backends. <br> Note: One API definition supports only one backend. | |
| `backend.http.baseUrl` | Your HTTP backend base URL | `https://backend:port/123` |
| `backend.http.certChain` | Optional, your backend certificate chain in PEM (base64) format. <br><br> It supports: <br> a. **File system** - Path must be relative to where `serverless.yml` is located. <br> b. **AWS Certificate ARN** <br> c. **AWS CloudFormation Export** - Exported value must contain a valid AWS Certificate ARN. | `file://certs/backend.cer` <br> (or) <br> `arn:aws:acm:..` <br> (or) <br> `!ImportValue xx` <br> (or) <br> `!Ref xx` |
| `backend.jms.destination` | Your JMS backend destination (queue or topic name) | `MY.BACKEND.TOPIC` |
| `backend.jms.destination` | Your JMS Destination (queue or topic name) | `MY.BACKEND.TOPIC` |
| `backend.jms.parameters` | List of JMS connection parameters to be used in `key`:`value` form as described [here](https://axis.apache.org/axis2/java/transports/jms.html). | `transport.jms.ConnectionFactory: 'My-ConnectionFactory'`|
| `mediationPolicies` | Optional, your choice of mediation policies (or) sequences. They can manipulate input/output/fault messages as described [here](https://docs.wso2.com/display/AM260/Adding+Mediation+Extensions) | |
| `mediationPolicies.in` | Input mediation policy, it manipulates the request going to your backend | `log_in_message` |
| `mediationPolicies.out` | Output mediation policy, it manipulates the response going back to your API consumer | `json_validator` |
| `mediationPolicies.fault` | Fault mediation policy, it manipulates the fault handling | `None` |
| `apiProperties` | Optional, List of API properties to be used in `key`:`value` form as described [here](https://docs.wso2.com/display/AM260/Adding+Custom+Properties+to+APIs) | `'property1': 'value1'`|
| `mediationPolicies` | Optional, your choice of mediation policies (or) sequences. They can manipulate input/output/fault messages as described [here](https://docs.wso2.com/display/AM260/Adding+Mediation+Extensions). | |
| `mediationPolicies.in` | Input mediation policy, it manipulates the request going to your backend. | `log_in_message` |
| `mediationPolicies.out` | Output mediation policy, it manipulates the response going back to your API consumer. | `json_validator` |
| `mediationPolicies.fault` | Fault mediation policy, it manipulates the fault handling. | `None` |
| `apiProperties` | Optional, List of API properties to be used in `key`:`value` form as described [here](https://docs.wso2.com/display/AM260/Adding+Custom+Properties+to+APIs). | `'property1': 'value1'`|
| `maxTps` | Max. Transactions per second, used for throttling. | `100` |
| `tags` | Tags as an array that show up in WSO2 consoles | |
| `tags` | Tags as an array that show up in WSO2 console. | |
| `swaggerSpec` | Swagger 2.0 / OpenAPI 3.0 specification in YML | |

---
Expand Down
Binary file added assets/fork-me-on-github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"main": "src/index.js",
"scripts": {
"lint": "eslint .",
"test:unit": "jest \"^(.*/)*(.*\\.)*(spec)\\.js$\"",
"test:e2e": "jest e2e",
"lint:fix": "eslint . --fix",
"test:unit": "jest \"^(.*/)*(.*\\.)*(spec)\\.js$\" --verbose --collectCoverage",
"test:e2e": "jest e2e --verbose",
"test": "jest",
"release:alpha": "release pre alpha",
"release:patch": "release patch",
Expand All @@ -30,23 +31,25 @@
],
"devDependencies": {
"axios": "^0.21.1",
"https": "^1.0.0",
"fs": "^0.0.1-security",
"split-ca": "^1.0.1",
"babel-eslint": "^10.1.0",
"chalk": "^4.1.0",
"eslint": "^7.20.0",
"eslint-plugin-jest": "^24.1.5",
"form-data": "^4.0.0",
"fs": "^0.0.1-security",
"https": "^1.0.0",
"jest": "^26.6.3",
"qs": "^6.9.6",
"release": "^6.3.0"
"release": "^6.3.0",
"split-ca": "^1.0.1"
},
"dependencies": {
"axios": "^0.21.1",
"https": "^1.0.0",
"form-data": "^4.0.0",
"fs": "^0.0.1-security",
"split-ca": "^1.0.1",
"https": "^1.0.0",
"qs": "^6.9.6",
"form-data": "^4.0.0",
"split-ca": "^1.0.1",
"swagger-parser": "^10.0.2"
}
}
Loading

0 comments on commit a9b4724

Please sign in to comment.