DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • APIs for Logistics Orchestration: Designing for Compliance, Exceptions, and Edge Cases
  • Building Data Pipelines With Jira API

Trending

  • The Role of Functional Programming in Modern Software Development
  • Recurrent Workflows With Cloud Native Dapr Jobs
  • Create Your Own AI-Powered Virtual Tutor: An Easy Tutorial
  • Fixing Common Oracle Database Problems
  1. DZone
  2. Data Engineering
  3. Databases
  4. RAML: Designing a Simple API

RAML: Designing a Simple API

In this tutorial, learn how to design a simple API by working with the RESTful API Modeling Language, complete with code and screenshots to illustrate the process.

By 
Tirapa Reddy Tondapu user avatar
Tirapa Reddy Tondapu
·
Apr. 26, 17 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
22.1K Views

Join the DZone community and get the full member experience.

Join For Free
  • The following procedure covers how to design and implement an online REST service and consume that service. The procedure describes an example API that has only one resource; for simplicity, the user details were hard-coded you can also implement a corresponding backend connection to get the actual user data based on the inputs.

Creating the Sample Project Name User_Information

Once you have started your Anypoint studio, click on File, New, and Mule Project as shown in the below screenshot:

Create a mule project

Enter the Project Name as `User_Information` and then click on Finish tab.

Project Folder Structure

Generating a Sample RAML Definition API (Creating sample.raml)

Right click on project (User_Information), click on New, click on RAML API Definition, and then enter the file name as "sample." Click on finish.

Creating Sample.raml file

As you can see in the below screenshot, a sample.raml file as been created with title "Sample AP."

Sample API

Configure a Service endpoint and document section using baseUri and documentation properties at the root level of RAML file, as shown in this screenshot:

Service Endpoint and documentation

baseUri: https://www.tirapareddy.com:8081/api

documentation:
- title: Home Page for Sample API
content: |
This example documentation forms part of a tutorial for a 
[RAML Turorial](https://docs.mulesoft.com/api-manager/design-raml-api-task) article.

Create a sample user-example.json response JSON file.

 {
"name":"Tirapa Reddy Tondapu",
"company":"Eidiko Systems Integrators",
"location":"Hyderabad"
}

Create a sample resource to get user details as shown in the below code block.

/userInfo/{id}:
  get:
  description: Retrieves details of a particular users
  responses:
    200:
      body:
        application/json:
          example: !include user-example.json


Now we have created a resource named "userInfo" that can be used to retrieve particular user information.

Generate Corresponding Flows for This Resource (userInfo) From the RAML File

In order to generate corresponding flows for the above userInfo resource we need to right click on sample.raml==> click on Mule ==> click on Generate flows from RAML as shown in the attached screenshot:Generating Flows

As you can see in the above screenshot once you click on "generate flows from RAML", it will generate sample.xml mule cofiguration file containing below items along with the  below attached HTTP listener  congiguration(i.e the application is running at hot "localhost" and post:8081)

  1. APIKit Router.

  2. APIKit Console.

  3. userInfo resource flow.

  4. Global exception strategy.HTTP Listener Configurations

Running The User_information Project

Right click on the project "User_information" then click "Run as" and then click on " Mule Application."

Once you click on "Mule Application," the project will be deployed as shown in the attached screenshot.

Deployed

As the project has been deployed, now it is accessible from http://localhost:8081/console once you browse this URL you will be able to see the below API details:

Sample API Console

You can now access the API resource "userInfo" by clicking on GET and the providing any id value as shown in the attached screenshot:

Final Output page of Sample API

You can also see entire source code at https://github.com/tirapa-eidiko/RAML_User_Information.

Thanks & Regards,

Tirapa Reddy Tondapu

API

Opinions expressed by DZone contributors are their own.

Related

  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • APIs for Logistics Orchestration: Designing for Compliance, Exceptions, and Edge Cases
  • Building Data Pipelines With Jira API

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!