Design API in Anypoint Studio 7.5

Last Updated on 11/05/2020 by Patryk Bandurski

New Anypoint Studio 7.5 came with an exiting feature. From now on, we can design our APIs in Studio instead of the Design Center. In this article, you will see how it works and how to use it. Let’s see if this can improve our day-to-day tasks.

Create an API

The first step must be taken in the Design Center. We need to create an API specification or API fragment. After that, we can proceed to the Anypoint Studio 7.5

Import an API

  • Right-click in Package Explorer and pick Import option
  • In Anypoint Studio section select API Specification from Design Center
  • Add Anypoint Platform account or reuse already signed in
  • In the search box type the name of the fragment or API specification and click Finish
Imported API specification in Anypoint Studio
Imported API specification in Anypoint Studio

The result of the import you can see on the screen above. I have downloaded Quiz-Admin-XAPI specification. One important thing to notice, next to the name of the imported project in square bracket we have the name of the git repository and branch name.

Yes, you read it correctly. Anypoint Platform has its own git repository for your specifications. The repository link looks like:

https://anypoint.mulesoft.com/git/[organization-id]/[api-id]

Working with API

Comparison with Design Center

I am used to the Design Center interface. The first to notice is that we don’t have rich code suggestions. On the other hand, what is provided in Anypoint Studio is sufficient to write your RAML files.

What is more, you need to forget the visualization of your API. This part I often use to validate the final look of my API specification. I prefer to know how it is seen by the clients.

The advantage of the design in AP is that we don’t need to move between our Studio and the web Anypoint Platform. I like also an integration with the GIT repository. I can put a meaningful commit message. Unlike the Anypoint Platform, it uses mainly “Autosafe“, like in the History screenshot below.

API Specification GIT history
API Specification GIT history

Developing your API

Manage dependencies

Usually, we reuse API fragments in an API. It is as easy as managing dependencies for Mule application – you can read more about this here.

So, we have already defined an API fragment published to Anypoint Exchange. To use it in your API, go to Anypoint Studio to ecxhange.json file. You will see the form, line in the screenshot below.

Manage your API via exchange.json file
Manage your API via exchange.json file

Click plus sign and click from Exchange. Add Dependencies to Project window search for the fragment you would like to import. After that, you will see referenced API spec like [name] [version] for example quiz [v1.0.0]

Refresh, update … git

You work with your API specification/fragment just like with any project that is shared using GIT. So you can download changes from Design Center by using pull, and publish your changed by committing and pushing it to the repository.

Easy and very convenient!

Publishing to Anypoint Exchange

You are ready with your specification. It is time to share your valuable assent. We can do this from Anyoint Studio as well. In order to do this, you need to have up to date version without any local changes – that make sense.

Right-click the name of the API with and from the context menu select Publish to Exchange. You should see Configure your API Specification to publish it to Exchange dialog.

There are some fields like Specification name, last published version. We can specify which asset and API version to publish.

Summary

I am a big enthusiast of working with Design Center and designing there API specifications. However, it is a good choice that I can do the same locally using Anypoint Studio. The great advantage is the usage of the source control repository. All of us should feel comfortable with GIT. I like how smooth the processes is in Anypoint Studio now. This is something I will definitely recommend to use to save some time.

However, I see some space for improvement. It would be very convenient if I could do a pull request and review them. This is very useful in order to deliver high-quality specifications. Last but not least, if we could attach it to company GIT/bitbucket repository it would be brilliant.

All in all I am very satisfied with this change. Cheers

Design API in Anypoint Studio 7.5

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top