2. REST is also called as representational state transfer.
The REST API lets us to interact with anything that can send an
HTTP request.
REST APIs are very easy to create and design and it supports
various methods like GET, POST, PUT, DELETE etc to perform
various types of operations.
In Mule, we can create and design a REST service various ways.
But, with the new specification of RAML, it became quite a easy
task to create, design and test our APIs as per our requirement.
3. Before we start, we will actually look into what RAML really is.
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.
Reference :- http://raml.org/
5. RAML can be designed in API designer.
API Designer is a standalone/embeddable editor for RAML
(RESTful API Modeling Language) written in JavaScript using
Angular.JS. By default, the editor uses an in-browser filesystem
stored in HTML5 Local storage.
API designer :- https://www.mulesoft.com/platform/api/api-
designer
With this tool/editor, we can design our APIs and test it there itself
using a mock service with the tool.
6. So, we need to log in into our account to start designing our APIs.
https://anypoint.mulesoft.com/#/signin
If we don’t have an account we can sign up and create one.
7. Once we sign in, we need to click APIs menu in the top right as follows:-
8. If we don’t have any API present there in our account, we can create a
new API by clicking the button as below :-
9. Now, a dialog box will arrive and we will be filling it by giving our API
name, Version name and a end point as follows :-
10. So, we will be creating our first RAML in the API designer as follows.:-
11. Now, we will add some more tags in the file like Protocols and Media Type
12. Resource :- Resources are identified by their relative URI, which MUST begin
with a slash (/).
13. Now we can add methods for our resources.
methods :- methods are operations that are performed on a resource.
There can be several methods applied on a resources such as :-
* GET
* POST
* PUT
* DELETE
and many more.
We will be seeing GET performed on our resource.
Methods also contains the properties like displayName and description
14. As you can see here, we applied GET method on our resource /product