Combining Different API Specifications to a Single API in Mule 4
This blog aims to give an idea of how we can implement two different API specifications or two different RAML in one application.
Join the DZone community and get the full member experience.
Join For FreeThis blog aims to give an idea of how we can implement two different API specifications or two different RAML in one application. As well as 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:
RAML for Weather API![Weather API/master]()
RAML for Order API![Order API/master]()
API specifications for both the APIs are created and published to exchange:
Order API Weather API
As the API is created and published. The next step will be creating the project in studio.
Creating the Project
We will first take the Order API and generate the flow for it.
Global configuration along with the 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.

Global Config:
The next step is to apply a 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 project on CloudHub:
As a next step, the API will be tested.
Testing
Client ID and Secret applied:
Order API
Provided authorization with the correct token:
Authorization not applied (Disabled):
Published at DZone with permission of Abhishek Bathwal. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments