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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Code and Connect: MCP + MuleSoft
  • Generic and Dynamic API: MuleSoft
  • Releasing MuleSoft API
  • How to Build an OpenAI Custom GPT With a Third-Party API

Trending

  • ScyllaDB in Enterprise Java: High-Performance NoSQL With Eclipse JNoSQL
  • Avoiding AI Debt as a Team
  • The Self-Hosting Math Changed While We Were Still Arguing About Sovereignty
  • Taming Parameter Sniffing in SQL Server 2022 With PSP Optimization

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. MuleSoft With OpenAPI Specification

MuleSoft With OpenAPI Specification

In this walkthrough, you'll learn about API design and management in MuleSoft using the OpenAPI Specification, formerly Swagger.

By 
Rakesh Kumar Jha
·
Dec. 08, 17 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
16.7K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

MuleSoft provides RESTful API Modeling Language (RAML), which makes it easy to manage the whole API lifecycle from design to sharing. Enterprises saw the benefits of RAML’s API-spec-centric approach, and the industry has since incorporated it broadly.

MuleSoft recently joined the OpenAPI Initiative of the Linux Foundation, and now MuleSoft’s Anypoint Platform explicitly supports OAS (OpenAPI Specification, formerly Swagger) for describing APIs. MuleSoft Design Center supports importing an OAS 2.0 specification in JSON or ZIP format from the file system. We can also import an OAS 2.0 specification from the internet.

In this article, we will demonstrate how we can use OAS 2.0 API Specification in MuleSoft for API design and implementations.

Let’s get started. First, we will use SwaggerHub (https://app.swaggerhub.com) to create our API Specification using OAS 2.0.

Image title

As shown in the above screen resource, “/persons/{personId}” has been created on the HTTP GET method to get the details of a particular person. There are two parameters has been defined in the spec, “personId” as URI parameter and "clientid" as a header parameter. As part of the service response, we have created schemas for both success and error scenarios.

In the SwaggerHub UI, we will validate the specification and do the mock testing on the API specification. Once the API specification gets validated and looks good, let’s download the API specification from SwaggerHub, as shown in the above screen. 

Now, we will use the downloaded OAS 2.0 API specification in MuleSoft Design Center.

Let's create a new API Specification in Mule Design Center and import the API specification, as shown in the below screen. Here we can import the OAS specification as a file or zip or from a URL.

Image title

Let’s browse the zip file which we downloaded from SwaggerHub and finish the import. The converted OAS code appears in RAML in the editor panel, as shown in below screen.

Image title

Please beware, there are some limitations and issues in this OAS to RAML conversion due to different annotations and formats of these two languages. This will be resolved going forward, but from our side, let’s mock test the API specifications to make sure the conversion happens well for the specification we just created.

Now we have a well-designed and tested RAML API specification which we can use to create Mule projects.

Let’s share our knowledge to expand our MuleSoft community.

Thank you!

MuleSoft OpenAPI Specification API

Opinions expressed by DZone contributors are their own.

Related

  • Code and Connect: MCP + MuleSoft
  • Generic and Dynamic API: MuleSoft
  • Releasing MuleSoft API
  • How to Build an OpenAI Custom GPT With a Third-Party API

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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