implementing raml in studio

Post on 16-Apr-2017

121 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Implementing RAML in StudioBy Anirban Sen Chowdhary

RAML which is also called as RESTful API Modeling Language, helps us to manage the whole api lifecycle starting from it’s design, develop to sharing.

It is basically build on top of YAML for describing RESTful APIs and provides all the information to describe an API.

We can use this RAML specification to design and build our APIs our Anypoint Studio.

Reference :- http://raml.org/

Let’s design RAML for our APIs in API Designer ???

RAML can be designed in:- 1) API designer.2) API Workbench

We will be designing in API designer and then import the RAML file in our Mule Studio to implement it and design our flow. We will go to Cloud based API designer here:- API designer :- https://www.mulesoft.com/platform/api/api-designer

Designing RAML for REST API

Once we sign in, we need to click APIs menu in the top right as follows:-

If we don’t have any API present there in our account, we can create a new API by clicking the button as below :-

So, we will be creating our first RAML in the API designer as follows.:-

We can see here our first simple RAML script that we designed in the API designer. This is a simple GET method example which will take a query parameter and display the response in JSON.

Testing our API in API Designer

Infact API designer platform provides an option to test our APIs that we build in it. In the left side we can see a button called Mocking Service, if we on that button, the API will be ready for a mock test. You can see in the code, that our baseUri has been commented and a new mock Uri is generated.

So, to test the API, we need to hit Try it button in the right side, that display our API graphically .:-

We can see our response is generated with status code 200:-

We can save our RAML file in the API designer by hitting the Save button.

Let’s build API in Anypoint Studio…..

In Anypoint Studio, We create a new Mule project as below.

Let’s give the project name as TestRAML, and add APIKit component in the project and refer our RAML file from our local system, where we downloaded the file from API designer

Once we click finish button, we can see Mule has created the project and flows are automatically created based on our RAML file we created.

Testing our API in Anypoint Studio

So, when we run our Mule application to test the API, we can see APIKit Console has started.:-

We can see the APIKit console in our browser after putting the url there.Now, we are ready to test our API in the browser with API console:-

So, finally after filling the query param and then hitting the GET button we get our response.

So we can see it is very easy to design and create a RAML file for our RESTful api using cloud based API designer implement this RAML file in our Mule using API Kit.

So at the end I can only say that, let’s spread our knowledge and expand our Mule community.

Thank You

top related