Integrate SwaggerHub with WSO2 API Manager in 2 Steps

Tanya Madurapperuma
3 min readAug 6, 2021

--

Introduction

If your organization is developing APIs using SwaggerHub, there are multiple advantages of getting them published into WSO2 API Manager.

WSO2 API Manager has a feature rich marketplace where API consumers can self on-board themselves to search and discover APIs. It also has socializing features like commenting, rating APIs etc. API Publishers can attach user guides or any supporting documents which helps their API consumers. As an API consumer once you’ve come across the API that will cater to your requirement you can subscribe to the API, generate required keys and tokens to try out the API using the API Manager itself. In the process of embedding the APIs into your application API Manager provides you the flexibility to generate SDKs for the API of your choice. Bottom line is WSO2 API Manager supports full lifecycle of the API Management.

Here’s a single two step process which you can follow to seamlessly publish your SwaggerHub apis into WSO2 API Manager.

Solution Overview

SwaggerHub has a git integration support which makes it possible for you to push your openAPI definition to a git repository after completing the design work.

Below given is the overview of the integration we are planning to do.

Step 1 : Login to your SwaggerHub account and configure git integration for your apis by following the instructions here. This allows you to push your changes from SwaggerHub into the git repository seamlessly.

In this example we have configured to publish the swagger json definition of the api along with a new folder for each API.

Step 2 : Once the APIs are pushed to the git repository we can configure a git action to create new APIs from the newly added swagger definitions to the repository. API Manager comes with a product REST API which we can use for this task.

Access token can be obtained as described in the Authentication section of the REST API document. Once a token is obtained we can call the REST API to create an API using an existing swagger definition as described here.

Once the API is created in the API Manager, an Id corresponding to the created api will be returned. We can store this Id against our API name so that we can use it at a later stage if we want to update the API which is already created.

So when an existing swagger definition is updated in the repository via the git sync from SwaggerHub we can call the API Update REST API as described here to update our API in the API Manager.

Once the git action is configured, everything else will be triggered without any intervention and new APIs will be created and existing API will be updated seamlessly.

A draft of such git action can be found here if you are looking for any reference.

NOTE : If you are trying this on a local machine make sure you use some supporting software like ngrok to expose your local development server to the Internet when configuring REST API urls.

Conclusion

WSO2 API Manager has the capability of creating an API using your swagger / Open API definition. If the APIs are developed using SwaggerHub then those API definitions can be seamlessly integrate to WSO2 API Manager to support the full life cycle of an API.

--

--