In this article we will see how we can create or generate Mule 4 project using RAML.
We will also see how Mule flow responds in case of Success and Validation scenarios.
RAML stands for RESTful API Modeling Language
RAML (Rest API Modeling Language) is based on YAML format, which is used to design REST APIs. RAML provides various features, including standardization, re-usability, easy readability, and much more. RAML provides a structure to the API which is useful for developers to start development process and it also helps clients to understands the request and response structure outcomes before hand.
What RAML contains?
- Endpoint URL with its Query parameters and URI parameters,
- HTTP methods to which API is listening to (GET, POST, PUT, DELETE),
- Request and response schema and sample message,
- HTTP response code that an API will return (eg: 200, 400, 404, 415, 500).
Lets jump into code build:
- Provide Project Name
- Select Runtime
- Import RAML file by specifying file location or URL
- Click finish button
Step 5: Check Success Scenario
- Request will be sent to HTTP listener endpoint.
- HTTP listener takes the request and forwards to APIKit router
- APIKit validates the incoming requests and passes it to designated flow.
- Here it is passing to “get:apikit-login:apikit-raml-flow-Mule4-config” flow
- Request is processed and gives a 200 OK response.
Flow execution sequence in Error Scenario(Bad Request)
On Api Console, When we execute DELETE operation.
- Enter incorrect value in Delete Id.
- Request will receive to HTTP endpoint and forwards to APIKit router.
- APIKit router validates the incoming request.
- On validation failed APIKit throws an error and which is caught by error handler.
- Error handler passes the flow execution to APIKIT:BAD_REQUEST scope and gives response with status code 400