SlideShare a Scribd company logo
API
RAML API Designing Basics
• Introduction
• RAML API Schema
• Root
• Resources
• Methods
• URI Parameters
• Query Parameters
• Responses
Introduction
What is RAML ?
• RAML : RESTful API Modeling Language.
• Non-proprietary, vendor-neutral open spec.
• Aims to help current API ecosystem and solve immediate problems,
and then gently encourage ever-better API patterns.
Why RAML ?
• Makes it easy to manage the whole API lifecycle from design to
sharing.
• Concise - you only write what you need to define.
• Reusable.
• Machine readable API design that is actually human friendly.
API Schema
Root
• Some basic information about the API. i.e. title, baseUri, version etc.
Resources
• Decides how API can be used by consumers.
Methods
• To define what consumers can do with the resources.
URI Parameters
• To have dynamic resources, to act upon the more granular objects of
the resources.
Query Parameters
• To be passed to methods, to extend the functionality of the API.
Responses
• HTTP status codes, may include descriptions, examples or schemas
Root
• Contains Some basic information about the API. i.e. title, baseUri,
version etc.
• Everything entered in at the root (or top) of the spec applies to the rest
of the API.
• Chosen baseURI will be used with every call made, hence make sure to
keep it clean and concise.
Example :
• #%RAML 0.8
• title: Employee Details Management
• version: v1
• baseUri:
https://mocksvc.mulesoft.com/mocks/c2a7ecf4-edd3-
4023-8373-c3a2cf325dda/api/{version}
Resources
• Decides how API can be used by consumers.
• Resources always begin with a slash ( / ) in RAML.
• Any methods and parameters nested under these top level resources
belong to and act upon that resource.
• Nesting of resources is also possible.
Example :
• /employees:
• /department:
• /region:
Methods
• To define what consumers can do with the resources.
• Most common HTTP methods :
• 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.
• Each HTTP method can only be used once per resource.
• Lower case must be used for methods in RAML API definition.
Example :
• /employees:
• get:
• post:
• put:
delete:
URI Parameters
• To have dynamic resources, to act upon the more granular objects of
the resources.
• Used for nesting of resources.
• A URI parameter is denoted by surrounding curly brackets in RAML.
Example :
• /employees:
• /{employeeName}:
• With above, to make a request to this nested resource, the URI for the
employee, ‘Thomas Anderson’ would look like
– http://api.EmpolyeeDet.com/v1/ employees/ Thomas Anderson
Query Parameters
• To be passed to methods, to extend the functionality of the API.
• To make developers to be able to perform more powerful actions, like
filtering a collection based on passed parameters.
• Query parameters may also be something that the server requires to
process the API consumer's request, like an access token.
Example :
• / employees :
• /{employeeName}
• get:
• queryParameters:
• employeeId :
• put:
• queryParameters:
• access_token:
Continue…
• Each query parameter may have any number of optional attributes to
further define it.
• Example :
• / employees :
• /{employeeName}
• get:
• queryParameters:
• employeeId :
• displayName: Employee Id
• type: string
• description: Id of an employee
• example: E001
• required: false
Responses
• A map of one or more HTTP status codes.
• Each response may include descriptions, examples or schemas
• Note the pipe ( | ) after ‘example’ keyword, it’s to indicate what follows
is a string, if not put, it’ll give an error saying, ‘example must be a
string’.
Example :
• / employees :
• /{employeeName}:
• get:
• description: Retrieves details of a specific employee
• responses:
• 200:
• body:
• application/json:
• example: |
• {
• …<sample data>
• },
• "success": true,
• "status": 200
• }
Example
• The main flow for a RAML-based API manages these functions:
• Exposes the API using HTTP or Jetty.
• Routes requests between the interface and the backend flows based on
the HTTP request.
• References exception strategies that produce HTTP-status-code responses.
Main Flow
Backend Flows
• APIkit generates a backend flow for each resource-action pairing in a
RAML. APIkit for SOAP generates a backend flow for each operation in a
WSDL. For example, the RAML interface receives the GET request for sales
of T-shirts. The backend flow accesses a database to look up sales data
and responds to the request.
Flights API
API
United
American
Delta
Front-end
UI
Mule ESB
Connection Details
United Airlines: RESTful web service
• URL: http://mu.mulesoft-training.com/essentials/united/flights
Delta Airlines: web service• URL:
• URL: http://mu.mulesoft-training.com/essentials/delta
American Airlines: MySQL database
• Server: mudb.mulesoft-training.com
• Port: 3306
• User: mule
• Password: mule
• Database: training
• American table: flights

More Related Content

What's hot

Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDFLeigh Dodds
 
Apache solr
Apache solrApache solr
Apache solr
Dipen Rangwani
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
Mohammed Safwat Abu Kwaik
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsanthony_putignano
 
Ember.js Self Defining Apps
Ember.js Self Defining AppsEmber.js Self Defining Apps
Ember.js Self Defining Apps
Oli Griffiths
 
CakePHP REST Plugin
CakePHP REST PluginCakePHP REST Plugin
CakePHP REST Plugin
Kevin van Zonneveld
 
RESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisRESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based Katharsis
Keith Moore
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
Ryan Szrama
 
Intro to php
Intro to phpIntro to php
Intro to php
NithyaNithyav
 
Request-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails AppRequest-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails App
Nathalie Steinmetz
 
Skillwise - Advanced web application development
Skillwise - Advanced web application developmentSkillwise - Advanced web application development
Skillwise - Advanced web application development
Skillwise Group
 
OData RESTful implementation
OData RESTful implementationOData RESTful implementation
OData RESTful implementation
Hari Wiz
 
Working with solr.pptx
Working with solr.pptxWorking with solr.pptx
Working with solr.pptx
alignminds
 
Asp.net
Asp.netAsp.net
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
Carol McDonald
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
Syed Awais Mazhar Bukhari
 
12 Introduction to Rails
12 Introduction to Rails12 Introduction to Rails
12 Introduction to Rails
Deepak Hagadur Bheemaraju
 
JSP Part 2
JSP Part 2JSP Part 2
JSP Part 2
DeeptiJava
 

What's hot (18)

Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDF
 
Apache solr
Apache solrApache solr
Apache solr
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIs
 
Ember.js Self Defining Apps
Ember.js Self Defining AppsEmber.js Self Defining Apps
Ember.js Self Defining Apps
 
CakePHP REST Plugin
CakePHP REST PluginCakePHP REST Plugin
CakePHP REST Plugin
 
RESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisRESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based Katharsis
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
 
Intro to php
Intro to phpIntro to php
Intro to php
 
Request-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails AppRequest-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails App
 
Skillwise - Advanced web application development
Skillwise - Advanced web application developmentSkillwise - Advanced web application development
Skillwise - Advanced web application development
 
OData RESTful implementation
OData RESTful implementationOData RESTful implementation
OData RESTful implementation
 
Working with solr.pptx
Working with solr.pptxWorking with solr.pptx
Working with solr.pptx
 
Asp.net
Asp.netAsp.net
Asp.net
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
12 Introduction to Rails
12 Introduction to Rails12 Introduction to Rails
12 Introduction to Rails
 
JSP Part 2
JSP Part 2JSP Part 2
JSP Part 2
 

Similar to Mule soft RAML API Designing

Api security-testing
Api security-testingApi security-testing
Api security-testing
n|u - The Open Security Community
 
Rest APIs Training
Rest APIs TrainingRest APIs Training
Rest APIs Training
Shekhar Kumar
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
amesar0
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
BIOVIA
 
API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0
Fabrizio Ferri-Benedetti
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
Lorna Mitchell
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API RecommendationsJeelani Shaik
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
Lorna Mitchell
 
restapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdfrestapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdf
mrle7
 
Rest API Testing
Rest API TestingRest API Testing
Rest API Testing
upadhyay_25
 
Basic auth implementation using raml in mule
Basic auth implementation using raml in muleBasic auth implementation using raml in mule
Basic auth implementation using raml in mule
Adithya Kuchan
 
Cakeph pppt
Cakeph ppptCakeph pppt
Cakeph pppt
Wizard Rider
 
Ei cakephp
Ei cakephpEi cakephp
Ei cakephp
eiei lay
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
Lorna Mitchell
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debate
Restlet
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
Jason Gerard
 
Api design and development
Api design and developmentApi design and development
Api design and development
oquidave
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes WorkshopErik Hatcher
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service DesignLorna Mitchell
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
Siddharth Sharma
 

Similar to Mule soft RAML API Designing (20)

Api security-testing
Api security-testingApi security-testing
Api security-testing
 
Rest APIs Training
Rest APIs TrainingRest APIs Training
Rest APIs Training
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
 
API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
restapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdfrestapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdf
 
Rest API Testing
Rest API TestingRest API Testing
Rest API Testing
 
Basic auth implementation using raml in mule
Basic auth implementation using raml in muleBasic auth implementation using raml in mule
Basic auth implementation using raml in mule
 
Cakeph pppt
Cakeph ppptCakeph pppt
Cakeph pppt
 
Ei cakephp
Ei cakephpEi cakephp
Ei cakephp
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debate
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
Api design and development
Api design and developmentApi design and development
Api design and development
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes Workshop
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
 

Recently uploaded

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 

Recently uploaded (20)

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 

Mule soft RAML API Designing

  • 1. API
  • 2. RAML API Designing Basics • Introduction • RAML API Schema • Root • Resources • Methods • URI Parameters • Query Parameters • Responses
  • 3. Introduction What is RAML ? • RAML : RESTful API Modeling Language. • Non-proprietary, vendor-neutral open spec. • Aims to help current API ecosystem and solve immediate problems, and then gently encourage ever-better API patterns. Why RAML ? • Makes it easy to manage the whole API lifecycle from design to sharing. • Concise - you only write what you need to define. • Reusable. • Machine readable API design that is actually human friendly.
  • 4. API Schema Root • Some basic information about the API. i.e. title, baseUri, version etc. Resources • Decides how API can be used by consumers. Methods • To define what consumers can do with the resources. URI Parameters • To have dynamic resources, to act upon the more granular objects of the resources. Query Parameters • To be passed to methods, to extend the functionality of the API. Responses • HTTP status codes, may include descriptions, examples or schemas
  • 5. Root • Contains Some basic information about the API. i.e. title, baseUri, version etc. • Everything entered in at the root (or top) of the spec applies to the rest of the API. • Chosen baseURI will be used with every call made, hence make sure to keep it clean and concise. Example : • #%RAML 0.8 • title: Employee Details Management • version: v1 • baseUri: https://mocksvc.mulesoft.com/mocks/c2a7ecf4-edd3- 4023-8373-c3a2cf325dda/api/{version}
  • 6. Resources • Decides how API can be used by consumers. • Resources always begin with a slash ( / ) in RAML. • Any methods and parameters nested under these top level resources belong to and act upon that resource. • Nesting of resources is also possible. Example : • /employees: • /department: • /region:
  • 7. Methods • To define what consumers can do with the resources. • Most common HTTP methods : • 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. • Each HTTP method can only be used once per resource. • Lower case must be used for methods in RAML API definition. Example : • /employees: • get: • post: • put: delete:
  • 8. URI Parameters • To have dynamic resources, to act upon the more granular objects of the resources. • Used for nesting of resources. • A URI parameter is denoted by surrounding curly brackets in RAML. Example : • /employees: • /{employeeName}: • With above, to make a request to this nested resource, the URI for the employee, ‘Thomas Anderson’ would look like – http://api.EmpolyeeDet.com/v1/ employees/ Thomas Anderson
  • 9. Query Parameters • To be passed to methods, to extend the functionality of the API. • To make developers to be able to perform more powerful actions, like filtering a collection based on passed parameters. • Query parameters may also be something that the server requires to process the API consumer's request, like an access token. Example : • / employees : • /{employeeName} • get: • queryParameters: • employeeId : • put: • queryParameters: • access_token:
  • 10. Continue… • Each query parameter may have any number of optional attributes to further define it. • Example : • / employees : • /{employeeName} • get: • queryParameters: • employeeId : • displayName: Employee Id • type: string • description: Id of an employee • example: E001 • required: false
  • 11. Responses • A map of one or more HTTP status codes. • Each response may include descriptions, examples or schemas • Note the pipe ( | ) after ‘example’ keyword, it’s to indicate what follows is a string, if not put, it’ll give an error saying, ‘example must be a string’. Example : • / employees : • /{employeeName}: • get: • description: Retrieves details of a specific employee • responses: • 200: • body: • application/json: • example: | • { • …<sample data> • }, • "success": true, • "status": 200 • }
  • 13.
  • 14. • The main flow for a RAML-based API manages these functions: • Exposes the API using HTTP or Jetty. • Routes requests between the interface and the backend flows based on the HTTP request. • References exception strategies that produce HTTP-status-code responses. Main Flow
  • 15. Backend Flows • APIkit generates a backend flow for each resource-action pairing in a RAML. APIkit for SOAP generates a backend flow for each operation in a WSDL. For example, the RAML interface receives the GET request for sales of T-shirts. The backend flow accesses a database to look up sales data and responds to the request.
  • 17. Connection Details United Airlines: RESTful web service • URL: http://mu.mulesoft-training.com/essentials/united/flights Delta Airlines: web service• URL: • URL: http://mu.mulesoft-training.com/essentials/delta American Airlines: MySQL database • Server: mudb.mulesoft-training.com • Port: 3306 • User: mule • Password: mule • Database: training • American table: flights

Editor's Notes

  1. /books: /{bookTitle} get: queryParameters: author: displayName: Author type: string description: An author's full name example: Mary Roach required: false publicationYear: displayName: Pub Year type: number description: The year released for the first time in the US example: 1984 required: false rating: displayName: Rating type: number description: Average rating (1-5) submitted by users example: 3.14 required: false isbn: displayName: ISBN type: string minLength: 10 example: 0321736079? put: queryParameters: access_token: displayName: Access Token type: string description: Token giving you permission to make call required: true
  2. /books: /{bookTitle}: get: description: Retrieve a specific book title responses: 200: body: application/json: example: | { "data": { "id": "SbBGk", "title": "Stiff: The Curious Lives of Human Cadavers", "description": null, "datetime": 1341533193, "genre": "science", "author": "Mary Roach", "link": "http://e-bookmobile.com/books/Stiff", }, "success": true, "status": 200 }