DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Beyond Manual Annotation: Engineering Self-Correcting Pseudo-Labeling Pipelines
  • Building Threat Intelligence Pipelines Using Python, APIs, and Elasticsearch
  • Implementing Secure API Gateways for Microservices Architecture
  • Contract-First Integration: Building Scalable Systems With Flyway, OpenAPI, and Kafka

Trending

  • OpenAPI From Code With Spring and Java: A Recipe for Your CI
  • How SaaS Architectures Break at Scale — and the Engineering Decisions That Prevent It
  • When Snowflake Lies to You: Understanding False Failures in dbt Pipelines
  • MuleSoft IDP: Enhancing Efficiency and Accuracy in Data Extraction
  1. DZone
  2. Data Engineering
  3. Databases
  4. Combining Different API Specifications to a Single API in Mule 4

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.

By 
Abhishek Bathwal user avatar
Abhishek Bathwal
·
Jan. 24, 21 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
9.3K Views

Join the DZone community and get the full member experience.

Join For Free

This 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 APIWeather API/master

RAML for Order APIOrder API/master

API specifications for both the APIs are created and published to exchange:

Projects and Assets UIs

We will also create the APIs in API Manager:

API Manager UI

Order API Weather API

Order API v1 and Weather API v2

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.

Generating the flow for the Order API

Global configuration along with the applied auto-discovery:

Global configuration and auto-discovery configuration

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.

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.

Properties for dual-api

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

'A new window will pop up'

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

Mule Project > APIs

Confirmation promptThe Weather API will be added as a module to the existing project, and the flow will be generated:

Added Weather API module

Global configuration along with the applied auto-discovery:

Global configuration and auto-discovery configuration (2)

As both the APIs are in a single project, the combined global element for both the APIs to a single global.xml along with the same HTTP config but two different paths.

Global Config:

Global configuration elements > HTTP Listener config

Path for Order API and Weather API:

Path for Order API and Weather API

The project is ready now that all the basic configurations are done.

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:

Weather API v2

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

Order API v1

Deployed project on CloudHub:

Deployed project on CloudHub

The policies are applied successfully and deployed too.

As a next step, the API will be tested.

Testing

Client ID and Secret applied:

test 1: Client ID and Secret applied

Client ID and Secret not applied (Disabled):

test 2: Client ID and Secret not applied

Order API

Provided authorization with the correct token:

test 3: provided authorization with correct token

Authorization not applied (Disabled):

test 4: authorization not applied

This concludes the blog, giving both an idea and overview of how we can implement or create a project using two different RAML files.


API

Published at DZone with permission of Abhishek Bathwal. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Beyond Manual Annotation: Engineering Self-Correcting Pseudo-Labeling Pipelines
  • Building Threat Intelligence Pipelines Using Python, APIs, and Elasticsearch
  • Implementing Secure API Gateways for Microservices Architecture
  • Contract-First Integration: Building Scalable Systems With Flyway, OpenAPI, and Kafka

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook