SlideShare a Scribd company logo
Designing ReST APIs with
RAML
Venkatanarayana k
ReST is abbreviated as representational state transfer.
The ReST API lets us to interact with anything that can send an HTTP/HTTPS request.
ReST APIs are very easy to create and design.
It supports various methods like GET, POST, PUT, DELETE etc to perform various types of
operations.
GET - Retrieve the information defined in the request URI.
PUT - Replace the addressed collection. At the object-level, create or update it.
POST - Create a new entry in the collection. This method is generally not used at the
object-level.
DELETE - Delete the information defined in the request URI.
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.
Before we start, we will actually look into what RAML really is.
RAML helps us to manage the whole API lifecycle starting from it’s design, develop to
sharing,Mocking.
It is basically build on top of YAML for describing ReSTful APIs and provides all the information
to describe an API.
How can we design RAML for our RESTAPIs
?
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
Login to Anypoint Cloud Hub : https://anypoint.mulesoft.com/login/#/signin
Click API Manager and Add new API.
With this tool/editor, we can design our APIs and test it there itself using a mock service with the
tool.
Designing RAML for REST API
The initial RAML file will contain ROOT section, which will describe the basic information of the API.
It includes API Title, API Version, BaseUri and all the BaseUri Parameters.
#%RAML 0.8 is the first line in the RAML and it describe the RAML version
Protocols :- The protocols property used to specify the protocols that an API supports. If the
protocols property is not specified, the protocol specified at the baseUri property is used.
Media Type :- The default media type returned by API responses, It can be overwrite by
specifying at Body of the response. This property is specified at the root level of the API
definition.
Both the above properties are optional though.
ADDING RESOURCES
Resource :- Resources are identified by their relative URI, which MUST begin with a slash (/).
Let’s add a resource say /pheripherals. So, we will have a resource named pheripherals which will also act
as a sub url of baseUri.
displayName :- The displayName attribute provides a friendly name to the resource and can be used by
documentation generation tools. This property is OPTIONAL.
description :- Each resource have a description that describe the resource. This property is OPTIONAL.
Adding Methods
Adding Query Parameters
Adding Response
get: Method defined under resource
/pheripherals.
To retrieve records, passing query parameter
ItemCode.
Described properties how an input
parameter Itemcode should be
type: string  It should be a string type.
required: true  specifying this parameter is
mandatory.
minLength: 4  should search at least with
4 characters
responses:  list of responses for a
method.
Reponses would be
2_ _ (200 series) : OK in the case of
success
4_ _(400 series) : Bad request if a
unsupported content type is requested, or
for any other invalid request
5_ _(500 series): Internal Server error
when something unexpected happens
during the request processing.
Refer Undistributed REST by Michael
Stowe.
body: describes return type of response
and structure of response.
CONTINUE IN RAML(PART2)

More Related Content

What's hot

Meetup #5 API Testing World
Meetup #5 API Testing WorldMeetup #5 API Testing World
Meetup #5 API Testing World
Malang QA Community
 
Web API testing : A quick glance
Web API testing : A quick glanceWeb API testing : A quick glance
Web API testing : A quick glance
Dhanalaxmi K
 
REST-API overview / concepts
REST-API overview / conceptsREST-API overview / concepts
REST-API overview / concepts
Patrick Savalle
 
Mule raml
Mule ramlMule raml
Mule raml
Ramakrishna Kapa
 
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauretapidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays
 
API Façade Pattern
API Façade PatternAPI Façade Pattern
API Façade Pattern
Nabeel Yoosuf
 
Api Testing
Api TestingApi Testing
Api Testing
Vishwanath KC
 
API Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 QuestionsAPI Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 Questions
QASource
 
APIs explained for product managers
APIs explained for product managersAPIs explained for product managers
APIs explained for product managers
Richard Holmes
 
4 Major Advantages of API Testing
4 Major Advantages of API Testing4 Major Advantages of API Testing
4 Major Advantages of API Testing
QASource
 
API 101 - Understanding APIs.
API 101 - Understanding APIs.API 101 - Understanding APIs.
API 101 - Understanding APIs.
Kirsten Hunter
 
Quantum API 1.1 proposal
Quantum API 1.1 proposalQuantum API 1.1 proposal
Quantum API 1.1 proposal
Salvatore Orlando
 
Why vREST?
Why vREST?Why vREST?
Why vREST?
vrest_io
 
Evaluating and Testing Web APIs
Evaluating and Testing Web APIsEvaluating and Testing Web APIs
Evaluating and Testing Web APIs
SmartBear
 
Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
clatimer
 
Selenium-4
Selenium-4Selenium-4
Selenium-4
Manoj Kumar Kumar
 
API Best Practices
API Best PracticesAPI Best Practices
API Best Practices
Sai Koppala
 

What's hot (17)

Meetup #5 API Testing World
Meetup #5 API Testing WorldMeetup #5 API Testing World
Meetup #5 API Testing World
 
Web API testing : A quick glance
Web API testing : A quick glanceWeb API testing : A quick glance
Web API testing : A quick glance
 
REST-API overview / concepts
REST-API overview / conceptsREST-API overview / concepts
REST-API overview / concepts
 
Mule raml
Mule ramlMule raml
Mule raml
 
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauretapidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
 
API Façade Pattern
API Façade PatternAPI Façade Pattern
API Façade Pattern
 
Api Testing
Api TestingApi Testing
Api Testing
 
API Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 QuestionsAPI Testing: Answers to Your Top 3 Questions
API Testing: Answers to Your Top 3 Questions
 
APIs explained for product managers
APIs explained for product managersAPIs explained for product managers
APIs explained for product managers
 
4 Major Advantages of API Testing
4 Major Advantages of API Testing4 Major Advantages of API Testing
4 Major Advantages of API Testing
 
API 101 - Understanding APIs.
API 101 - Understanding APIs.API 101 - Understanding APIs.
API 101 - Understanding APIs.
 
Quantum API 1.1 proposal
Quantum API 1.1 proposalQuantum API 1.1 proposal
Quantum API 1.1 proposal
 
Why vREST?
Why vREST?Why vREST?
Why vREST?
 
Evaluating and Testing Web APIs
Evaluating and Testing Web APIsEvaluating and Testing Web APIs
Evaluating and Testing Web APIs
 
Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
 
Selenium-4
Selenium-4Selenium-4
Selenium-4
 
API Best Practices
API Best PracticesAPI Best Practices
API Best Practices
 

Similar to Raml part 1

RAML - The architecture
RAML  - The architectureRAML  - The architecture
RAML - The architecture
Ankush Sharma
 
Rest With Raml
Rest With RamlRest With Raml
Rest With Raml
vijay dhanakodi
 
Lunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's GuideLunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's Guide
Lunacloud
 
API Testing Basics.pptx
API Testing Basics.pptxAPI Testing Basics.pptx
API Testing Basics.pptx
VikasGupta92111
 
Standards of rest api
Standards of rest apiStandards of rest api
Standards of rest api
Maýur Chourasiya
 
Slim Framework
Slim FrameworkSlim Framework
Slim Framework
Pramod Raghav
 
Best practices and advantages of REST APIs
Best practices and advantages of REST APIsBest practices and advantages of REST APIs
Best practices and advantages of REST APIs
Aparna Sharma
 
Apitesting.pptx
Apitesting.pptxApitesting.pptx
Apitesting.pptx
NamanVerma88
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce Integration
Er. Prashant Veer Singh
 
Api design and development
Api design and developmentApi design and development
Api design and development
oquidave
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
Evan Mullins
 
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
Jitendra Bafna
 
Play with force.com metadata
Play with force.com metadataPlay with force.com metadata
Play with force.com metadata
Rakesh Kumar Kedia
 
API Basics
API BasicsAPI Basics
API Basics
Ritul Chaudhary
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John Hardy
ManageIQ
 
Super simple introduction to REST-APIs (2nd version)
Super simple introduction to REST-APIs (2nd version)Super simple introduction to REST-APIs (2nd version)
Super simple introduction to REST-APIs (2nd version)
Patrick Savalle
 
Rest web service
Rest web serviceRest web service
Rest web service
Hamid Ghorbani
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
sunniboy
 
API Design- Best Practices
API Design-   Best PracticesAPI Design-   Best Practices
API Design- Best Practices
Prakash Bhandari
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architecture
Romain Rochegude
 

Similar to Raml part 1 (20)

RAML - The architecture
RAML  - The architectureRAML  - The architecture
RAML - The architecture
 
Rest With Raml
Rest With RamlRest With Raml
Rest With Raml
 
Lunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's GuideLunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's Guide
 
API Testing Basics.pptx
API Testing Basics.pptxAPI Testing Basics.pptx
API Testing Basics.pptx
 
Standards of rest api
Standards of rest apiStandards of rest api
Standards of rest api
 
Slim Framework
Slim FrameworkSlim Framework
Slim Framework
 
Best practices and advantages of REST APIs
Best practices and advantages of REST APIsBest practices and advantages of REST APIs
Best practices and advantages of REST APIs
 
Apitesting.pptx
Apitesting.pptxApitesting.pptx
Apitesting.pptx
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce Integration
 
Api design and development
Api design and developmentApi design and development
Api design and development
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
 
Play with force.com metadata
Play with force.com metadataPlay with force.com metadata
Play with force.com metadata
 
API Basics
API BasicsAPI Basics
API Basics
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John Hardy
 
Super simple introduction to REST-APIs (2nd version)
Super simple introduction to REST-APIs (2nd version)Super simple introduction to REST-APIs (2nd version)
Super simple introduction to REST-APIs (2nd version)
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 
API Design- Best Practices
API Design-   Best PracticesAPI Design-   Best Practices
API Design- Best Practices
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architecture
 

Recently uploaded

FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
maazsz111
 

Recently uploaded (20)

FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
 

Raml part 1

  • 1. Designing ReST APIs with RAML Venkatanarayana k
  • 2. ReST is abbreviated as representational state transfer. The ReST API lets us to interact with anything that can send an HTTP/HTTPS request. ReST APIs are very easy to create and design. It supports various methods like GET, POST, PUT, DELETE etc to perform various types of operations. GET - Retrieve the information defined in the request URI. PUT - Replace the addressed collection. At the object-level, create or update it. POST - Create a new entry in the collection. This method is generally not used at the object-level. DELETE - Delete the information defined in the request URI.
  • 3. 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. Before we start, we will actually look into what RAML really is. RAML helps us to manage the whole API lifecycle starting from it’s design, develop to sharing,Mocking. It is basically build on top of YAML for describing ReSTful APIs and provides all the information to describe an API.
  • 4. How can we design RAML for our RESTAPIs ?
  • 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 Login to Anypoint Cloud Hub : https://anypoint.mulesoft.com/login/#/signin Click API Manager and Add new API. With this tool/editor, we can design our APIs and test it there itself using a mock service with the tool.
  • 7. The initial RAML file will contain ROOT section, which will describe the basic information of the API. It includes API Title, API Version, BaseUri and all the BaseUri Parameters. #%RAML 0.8 is the first line in the RAML and it describe the RAML version
  • 8. Protocols :- The protocols property used to specify the protocols that an API supports. If the protocols property is not specified, the protocol specified at the baseUri property is used. Media Type :- The default media type returned by API responses, It can be overwrite by specifying at Body of the response. This property is specified at the root level of the API definition. Both the above properties are optional though.
  • 10. Resource :- Resources are identified by their relative URI, which MUST begin with a slash (/). Let’s add a resource say /pheripherals. So, we will have a resource named pheripherals which will also act as a sub url of baseUri. displayName :- The displayName attribute provides a friendly name to the resource and can be used by documentation generation tools. This property is OPTIONAL. description :- Each resource have a description that describe the resource. This property is OPTIONAL.
  • 11. Adding Methods Adding Query Parameters Adding Response
  • 12. get: Method defined under resource /pheripherals. To retrieve records, passing query parameter ItemCode. Described properties how an input parameter Itemcode should be type: string  It should be a string type. required: true  specifying this parameter is mandatory. minLength: 4  should search at least with 4 characters
  • 13. responses:  list of responses for a method. Reponses would be 2_ _ (200 series) : OK in the case of success 4_ _(400 series) : Bad request if a unsupported content type is requested, or for any other invalid request 5_ _(500 series): Internal Server error when something unexpected happens during the request processing. Refer Undistributed REST by Michael Stowe. body: describes return type of response and structure of response.