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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
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
Partner Zones AWS Cloud
by AWS Developer Relations
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
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

Designing and Documenting Your APIs Using RAML

To design a good API, you must use HTTP verbs properly using REST, but you also need to implement an intuitive design, good documentation, and a faithful representation of implementation.

Adrian Alonso user avatar by
Adrian Alonso
·
Jun. 17, 16 · Tutorial
Like (19)
Save
Tweet
Share
20.61K Views

Join the DZone community and get the full member experience.

Join For Free

Most of the projects in which we participate in my work designing and implementing APIs require access to mobile applications and web apps. This design requires defining an authentication system (e.g. one based on tokens such as JWT) and each of the endpoints that will be accessible. In this definition of endpoints we must decide on input fields and outputs for each.

To design a good API, you must use HTTP verbs properly using REST, but you also need to implement an intuitive design, good documentation, and a faithful representation of implementation. A part of that implementation is good, it is very important that the documentation associated with it is complete and is current by 100% having controlled the expected behavior for each request. In my opinion, keeping this commitment is usually quite complicated, but using the right tools can simplify the process and benefit the development team, and future developers can instruct the software development better.

After several months considering this, we decided to use RAML to document and design our APIs, although we were considering other solutions like Swagger. Let's detail what RAML is and how it works.

What Is RAML and Why Use It in Our APIs?

RAML is an acronym for "Restful API Modeling Language" and is a modeling language to define REST APIs with a fairly simple and easily understandable syntax for both humans and software systems. This language allows you to define resources, methods, parameters, responses, media types, and other basic HTTP components. Basically it is a non-proprietary and fully independent specification based on YAML and JSON. In other words, it allows us to write the specification of the APIs following a standard.

The great advantage of implementing a RAML API is that you focus completely on the "contract" that provides the endpoint; this allows you to start generating the documentation, which, once ready, provides different generators to generate the basic service "scaffolding" and even services that return answers, simulated to start our testing.

This methodology favors the testing process, providing us with the perfect environment to use TDD. Basically, we define the API, write tests to consume this API and started building the actual implementation and necessary tests to validate both the specification as described.

How to Write RAML

You can write just a normal file with the extension .raml and process it with different tools. Personally, we use an official tool called API MuleSoft Designer (https://github.com/mulesoft/api-designer). This tool is an editor built with AngularJS and you can install through NPM on your computer.

npm install -g api-designer


Some Useful Tools

  • JS RAML Parser: https://github.com/raml-org/raml-js-parser

  • RAML Java parser: https://github.com/raml-org/raml-java-parser

  • RAML SOAPUI Plugin: https://github.com/SmartBear/soapui-raml-plugin

I recommend watching the official tutorial to start creating your files RAML.

Software development

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • NoSQL vs SQL: What, Where, and How
  • Introduction to Containerization
  • The Power of Docker Images: A Comprehensive Guide to Building From Scratch
  • mTLS Everywere

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: