Implementing raml in studio

24
Implementing RAML in Studio By Anirban Sen Chowdhary

Transcript of Implementing raml in studio

Page 1: Implementing raml in studio

Implementing RAML in StudioBy Anirban Sen Chowdhary

Page 2: Implementing raml in studio

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/

Page 3: Implementing raml in studio

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

Page 4: Implementing raml in studio

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

Page 5: Implementing raml in studio

Designing RAML for REST API

Page 6: Implementing raml in studio

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

Page 7: Implementing raml in studio

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

Page 8: Implementing raml in studio

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

Page 9: Implementing raml in studio

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.

Page 10: Implementing raml in studio

Testing our API in API Designer

Page 11: Implementing raml in studio

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.

Page 12: Implementing raml in studio

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

Page 13: Implementing raml in studio

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

Page 14: Implementing raml in studio

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

Page 15: Implementing raml in studio

Let’s build API in Anypoint Studio…..

Page 16: Implementing raml in studio

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

Page 17: Implementing raml in studio

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

Page 18: Implementing raml in studio

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.

Page 19: Implementing raml in studio

Testing our API in Anypoint Studio

Page 20: Implementing raml in studio

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

Page 21: Implementing raml in studio

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:-

Page 22: Implementing raml in studio

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

Page 23: Implementing raml in studio

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.

Page 24: Implementing raml in studio

Thank You