How to Design APIs Using Anypoint Code Builder
What is Anypoint Code Builder?
Anypoint Code Builder is MuleSoft’s next generation Integrated Development Environment (IDE) that is part of the Anypoint Platform by MuleSoft. It allows developers to design, develop, and deploy APIs, integrations, and automations from a single environment.
How is the code builder useful for the developers?
Using Anypoint Code Builder, developers can write, test, and deploy MuleSoft applications entirely in the cloud without the need for any local installations. The tool provides a visual interface for designing APIs and integrations and supports the creation of custom connectors, data transformations, and other components.
Anypoint Code Builder is designed to accelerate the development process by providing templates, pre-built connectors, and code snippets. It also provides collaboration features that allow multiple developers to work on the same project simultaneously, reducing the time and effort required to create complex integrations.
Prerequisites
- Create an test account on Anypoint Platform.
Installation:
Step-1:
To use the code builder, first login to Anypoint Platform. Click on Code Builder.
Step-2:
Accept the terms and conditions to get the access
Step-3:
Click the launch Web IDE
Step-4:
Select the theme to get started on the design of an API.
Step-5:
Select the Design an API to start our project.
Demo:
Now, Design APIs Using Anypoint Code Builder
Below are the steps we are using to design an API in Anypoint Code Builder.
- Design the API
- Test the API using Mock service
- Push and commit our changes to design center
- Publish to exchange
Step-1: Design the API.
Click on Design An API
Enter the API specification and click Create Project.
Click Allow. It will redirect to the Anypoint Platform page and close the page.
Click YES
Now we got an access to design the API.
Use the below API for your testing.
testcodebuilder.raml
#%RAML 1.0
title: TestCodeBuilder
version: 1.0
types:
EmpDataType: !include Examples/EmpDataType.raml
/Employees:
get:
responses:
200:
body:
application/json:
type: EmpDataType[]
examples:
output: !include Examples/GetAllEmployees.raml
post:
body:
application/json:
type: EmpDataType
examples:
input: !include Examples/PostEmployee.raml
responses:
201:
body:
application/json:
example:
output: Employee has been added successfully
/{EmpID}:
get:
responses:
200:
body:
application/json:
type: EmpDataType
examples:
output: !include Examples/GetSingleEmployee.raml
Examples:
EmpDataType.raml
#%RAML 1.0 DataType
type: object
properties:
EmpID?: integer
EmpName: string
EmpSalary: integer
EmpJoiningYear: integer
EmpDepartment: string
GetAllEmployees.raml
#%RAML 1.0 NamedExample
value:
-
EmpID: 001
EmpName: Sudheer
EmpSalary: 12345
EmpJoiningYear: 2023
EmpDepartment: IT
-
EmpID: 002
EmpName: sai
EmpSalary: 1234
EmpJoiningYear: 2023
EmpDepartment: Network
GetSingleEmployee.raml
#%RAML 1.0 NamedExample
value:
EmpID: 001
EmpName: Sudheer
EmpSalary: 12345
EmpJoiningYear: 2023
EmpDepartment: IT
PostEmployee.raml
#%RAML 1.0 NamedExample
value:
EmpID: 003
EmpName: paul
EmpSalary: 123456
EmpJoiningYear: 2023
EmpDepartment: Management
Step-2: Test the API using Mock service
Click the right side corner of the API console to do the mock testing.
Step-3: Push and commit our changes to design center
Click the Source Control (Left side corner below search symbol) to push and commit our changes.
After opened the Source Control, Click the Plus (+) button for the stage changes.
After the stage changes, Add the comments and click the Commit button.
Below popup displayed and click Yes
Go to design center and check the API.
Step-4: Now Publish the API to exchange
Conclusion:
In this article, we learned how to design an API using Code Builder.
- Design the API
- Test the API using Mock service
- Push and commit our changes to design center
- Publish to exchange
Thanks for reading my post and I hope it will be helpful.
-Sudheer Kumar N