A Complete Walkthrough of OpenAPI Support in MuleSoft

Written by Muhammad Aqib Arif

MuleSoft Integration Architect

Over the last couple of years, the API revolution has been incredible; the APIs have become the standard for all software applications. It is no longer just a tool for hardcore developers, but anyone can use it. The API description languages are ways to explain APIs' behavior, and OpenAPI specification is one of those description languages.

What Is OpenAPI Specification (OAS)?

OpenAPI Specification, also known as Swagger specification, is an API description format for REST APIs. An OpenAPI file allows describing the entire API, including endpoints, operations, parameters, authentication methods, etc. The API specifications can be written in YAML or JSON. Thus, the format is easy to learn and readable to both humans and machines.

OpenAPI Support in MuleSoft

Mulesoft has added support for implementing APIs with the OAS 3.0 format in Anypoint studio and also introduced the ability to scaffold OAS 3.0 API specifications to Mule flows. It has also introduced the transition from design to deploy by including support for testing and debugging the APIs within Anypoint Studio. And finally, updated API Manager to allow management of APIs in the OAS 3.0 format, Mule and non-Mule, with API gateways and proxies.

Benefits of OpenAPI Specification

  • Design First: We can design the whole API with types and examples for every endpoint before implementing it. Also, we can verify if everything looks as expected with the help of tools that generate mock APIs.
  • Auto Code Generators: OpenAPI is the REST-based specification with the multi-language supported by the code generators, which creates server stubs in the language of our choice, and we can wire it up with our backend services and databases.
  • Tooling: The Swagger specification was donated to the OpenAPI foundation, and it was renamed to OpenAPI specification. However, a huge ecosystem of tools created under the Swagger brand can be used to speed up the API development process.
  • Large Community: OpenAPI is used and backed by many big organizations and can be seen as their condensed knowledge of building hundreds of APIs over the years.
  • Stable Implementation: The OpenAPI spec was known as Swagger spec until 2017, as it isn’t the first version of the spec. After that, it’s version 3.0, were rebranded from Swagger to OpenAPI.

Design APIs using OAS 3.0 in MuleSoft

Follow the steps below to design a simple Employee API using OpenAPI specification in MuleSoft

  • Go to Anypoint platform (anypoint.mulesoft.com) and select Design Center from the left menu
  • Let’s click on Create new button and select New API Spec from the dropdown menu
  • Now, we need to define the API Title & Specification language. We can select OAS 3.0 for Specification Language as we’re going to design the API using OAS 3.0
  • The API Designer should appear now where we can write the API Specification
  • We can now add resources under the paths section in API Designer; for this example, let’s add a resource with GET mwthod as mentioned in the image below
  • The simple Employee API has been designed using OAS 3.0

So, the above example shows how we can design the API using OAS 3.0.

Look at the below table that describes the support of OAS 3.0 by all the products in Anypoint Platform for the API lifecycle stages of design, publish, and manage.

API Lifecycle Stage Product OAS 3.0 Supported?
Design API Designer Yes
Design Anypoint Studio Yes
Publish Anypoint Exchange Yes
Publish REST Connect Yes
Implement Anypoint Studio Yes
Deploy Mule runtime engine Yes
Operate API Manager Yes

Royal Value Add to the Customer

The customer needed to implement the API designing solution, which should have a wide range of communities, and at the same time found it challenging to adopt a platform with a 360-degree view where everything comes on one plate. For example, API Security, API Portal, API Monitoring, API Visualizer, DevOps activities, and much more. So, Royal Cyber came up with the Solution to use OAS 3.0 for API designing and a 360-degree view platform as MuleSoft. Find more below how Royal Cyber added value for the customer.

The customer gained the following benefits with the help of Royal Cyber,

  • Integrated 360-degree view to understand and look forward to customer needs.

  • Improved agility with a flexible and evolving architecture.

  • Enhanced API security with the help of API Manager capabilities.

  • Covered the simple, fast, and reliable process of designing and developing APIs.

  • Greater ROI and happy customers.

  • Implementation of Design first approach.

Royal Cyber Delivering Connected Experiences

MuleSoft’s Anypoint Platform empowers everyone in the company — from IT to LoB, from a small enterprise to a big organization, from integration to API management — to unlock application's data and devices and go digital.

At Royal Cyber, we are excited to deliver innovations to empower everyone to create connected experiences. With MuleSoft's Anypoint Platform's power, we are steering towards the dream of enabling the composable enterprise – where digital capabilities can be created from existing applications using APIs. For more information, or to try Anypoint Platform you can email us at [email protected] or visit www.royalcyber.com.

Leave a Reply