Author: Abhishek Bathwal

This Blog is to give an idea of how we can implement two different API specifications or two different RAML in one application. And also generate two different main flows with different resources along with applying two different policies to each API.

So let’s first create two different API Specifications.

  1. Weather API
  2. Order API

RAML for Weather API

RAML for Order API

API specifications for both the API are created and published to exchange.

Will also create the APIs in API Manager.

Order API     Weather API

As the API is created and published. The Next step will be creating the project in studio.

Creating the Project

Will First take the Order API and generate the flow for it.

Global configuration along with applied Auto discovery

One part is done. The Implementation of Order API.

Now the second part is to add the RAML for Weather API.

Limitation: Two different RAML cannot be generated from a single API folder one may overwrite the other.

So to overcome this we need to import the RAML for Weather API as a module.

Import Weather API

For that Right click on the Project -> Manage Dependencies -> Manage Modules

A window will open in that under Mule Project -> APIs -> To the right in the APIs box click the (+) plus symbol -> from Exchange

A new Window will pop up, In that Search for Weather API -> Add -> Finish

Once the above steps are done then the API will be added to the APIs section, just Apply and Close and generate the Scaffold.

The Weather API will be added as a Module to the existing project and the flow will be generated.

Global configuration along with applied Auto discovery

As both the APIs are in a single project so combined the global element for both the APIs to a single global.xml along with Same HTTP config but two different Paths.

Global Config

Path for Order API and Weather API

The Project is Ready all the Basic configurations are done.

Next Step is to apply policy, Deploy and Test the Application.

Apply Policy And Deploy the API

Client Id enforcement is Applied on Weather API

OAuth 2.0 access token enforcement using MuleSoft is applied on Order API

Deployed the Project on CloudHub

The Policies are applied successfully and deployed too.

As a next step the API will be tested.

Testing

  1. Weather API

Client Id and Secret Applied

Client Id and Secret Not Applied (Disabled)

2. Order API

Provided Authorization with correct token 

Authorization Not applied (Disabled)

This concludes with giving an idea or overview on how we can implement or create a project using two different RAML files.

Leave a Comment