SlideShare une entreprise Scribd logo
1  sur  14
RAML API Designing Basics
Part 1
• Introduction
• RAML API Schema
• Root
• Resources
• Methods
• URI Parameters
• Query Parameters
• Responses
• 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.
Introduction
• 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.
Introduction
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
• 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}
Root
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:
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:
• 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
Query
Parameters
• To make a GET call, the URI looks like
http://api.EmpolyeeDet.com/v1/ employees/ Thomas Anderson?
employeeId =E001
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>
Example
Root
Resource
URI Parameter
Method
Query Parameter
Response
Note The Pipe
Thank You

Contenu connexe

Tendances

Tendances (20)

Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Kong API Gateway
Kong API Gateway Kong API Gateway
Kong API Gateway
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
 
Gathering Operational Intelligence in Complex Environments at Splunk
Gathering Operational Intelligence in Complex Environments at SplunkGathering Operational Intelligence in Complex Environments at Splunk
Gathering Operational Intelligence in Complex Environments at Splunk
 
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys MeetupsMuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
 
Designing and building Mule applications
Designing and building Mule applicationsDesigning and building Mule applications
Designing and building Mule applications
 
Kafka presentation
Kafka presentationKafka presentation
Kafka presentation
 
IBM API Connect - overview
IBM API Connect - overviewIBM API Connect - overview
IBM API Connect - overview
 
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
 
Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...
Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...
Brisbane MuleSoft Meetup 2023-03-22 - Anypoint Code Builder and Splunk Loggin...
 
Managing APIs with MuleSoft
Managing APIs with MuleSoftManaging APIs with MuleSoft
Managing APIs with MuleSoft
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API Gateway
 
Highlights of WSO2 API Manager 4.0.0
Highlights of WSO2 API Manager 4.0.0Highlights of WSO2 API Manager 4.0.0
Highlights of WSO2 API Manager 4.0.0
 
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache KafkaReal-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
 
Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...
Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...
Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...
 
OpenAPI 3.0, And What It Means for the Future of Swagger
OpenAPI 3.0, And What It Means for the Future of SwaggerOpenAPI 3.0, And What It Means for the Future of Swagger
OpenAPI 3.0, And What It Means for the Future of Swagger
 
Logging best practice in mule using logger component
Logging best practice in mule using logger componentLogging best practice in mule using logger component
Logging best practice in mule using logger component
 
(SEC323) New: Securing Web Applications with AWS WAF
(SEC323) New: Securing Web Applications with AWS WAF(SEC323) New: Securing Web Applications with AWS WAF
(SEC323) New: Securing Web Applications with AWS WAF
 
Kong
KongKong
Kong
 
AWS WAF introduction and live demo - Pop-up Loft Tel Aviv
AWS WAF introduction and live demo - Pop-up Loft Tel AvivAWS WAF introduction and live demo - Pop-up Loft Tel Aviv
AWS WAF introduction and live demo - Pop-up Loft Tel Aviv
 

En vedette

I Love APIs 2015 API Lab Design-first API Development Using Node and Swagger
I Love APIs 2015 API Lab Design-first API Development Using Node and SwaggerI Love APIs 2015 API Lab Design-first API Development Using Node and Swagger
I Love APIs 2015 API Lab Design-first API Development Using Node and Swagger
Apigee | Google Cloud
 

En vedette (20)

Birds Eye View on API Development - v1.0
Birds Eye View on API Development - v1.0Birds Eye View on API Development - v1.0
Birds Eye View on API Development - v1.0
 
Battelfield REST, API Development from the trenches
Battelfield REST, API Development from the trenchesBattelfield REST, API Development from the trenches
Battelfield REST, API Development from the trenches
 
Raml api designer
Raml   api designerRaml   api designer
Raml api designer
 
Managing api development
Managing api developmentManaging api development
Managing api development
 
API World 2016 - A five-sided prism polarizing Web API development
API World 2016 - A five-sided prism polarizing Web API developmentAPI World 2016 - A five-sided prism polarizing Web API development
API World 2016 - A five-sided prism polarizing Web API development
 
I Love APIs 2015 API Lab Design-first API Development Using Node and Swagger
I Love APIs 2015 API Lab Design-first API Development Using Node and SwaggerI Love APIs 2015 API Lab Design-first API Development Using Node and Swagger
I Love APIs 2015 API Lab Design-first API Development Using Node and Swagger
 
Design-first API Development using Swagger and Node
Design-first API Development using Swagger and NodeDesign-first API Development using Swagger and Node
Design-first API Development using Swagger and Node
 
Mulethenewtechnology 12549172699166-phpapp03-160421133841
Mulethenewtechnology 12549172699166-phpapp03-160421133841Mulethenewtechnology 12549172699166-phpapp03-160421133841
Mulethenewtechnology 12549172699166-phpapp03-160421133841
 
Mule debugging managing_stack_traces
Mule debugging managing_stack_tracesMule debugging managing_stack_traces
Mule debugging managing_stack_traces
 
Mule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_muleMule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_mule
 
Mule Custom Aggregator
Mule Custom AggregatorMule Custom Aggregator
Mule Custom Aggregator
 
Summer School: Achievements and Applications of Contemporary Informatics, Mat...
Summer School: Achievements and Applications of Contemporary Informatics, Mat...Summer School: Achievements and Applications of Contemporary Informatics, Mat...
Summer School: Achievements and Applications of Contemporary Informatics, Mat...
 
Mule concepts connectors
Mule concepts connectorsMule concepts connectors
Mule concepts connectors
 
Mule concepts filters scopes_routers
Mule concepts filters scopes_routersMule concepts filters scopes_routers
Mule concepts filters scopes_routers
 
Mule scopes 1
Mule scopes 1Mule scopes 1
Mule scopes 1
 
Mule concepts transformers
Mule concepts transformersMule concepts transformers
Mule concepts transformers
 
Mule scopes 2
Mule scopes 2Mule scopes 2
Mule scopes 2
 
Mule mel 1
Mule mel 1Mule mel 1
Mule mel 1
 
Mule esb-connectors
Mule esb-connectorsMule esb-connectors
Mule esb-connectors
 
Scrum and Agile SDLC 101
Scrum and Agile SDLC 101Scrum and Agile SDLC 101
Scrum and Agile SDLC 101
 

Similaire à Design API using RAML - basics

Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
Lorna Mitchell
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
Jeelani Shaik
 

Similaire à Design API using RAML - basics (20)

Mule soft RAML API Designing
Mule soft RAML API DesigningMule soft RAML API Designing
Mule soft RAML API Designing
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
 
Recipes for API Ninjas
Recipes for API NinjasRecipes for API Ninjas
Recipes for API Ninjas
 
RAML - The architecture
RAML  - The architectureRAML  - The architecture
RAML - The architecture
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
Rest APIs Training
Rest APIs TrainingRest APIs Training
Rest APIs Training
 
A Beginner's Guide to Ember
A Beginner's Guide to EmberA Beginner's Guide to Ember
A Beginner's Guide to Ember
 
API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0
 
Api design and development
Api design and developmentApi design and development
Api design and development
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
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)
 
Documenting REST APIs
Documenting REST APIsDocumenting REST APIs
Documenting REST APIs
 
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
 
POSTMAN.pptx
POSTMAN.pptxPOSTMAN.pptx
POSTMAN.pptx
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
 
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
 
Integration on Force.com Platform
Integration on Force.com PlatformIntegration on Force.com Platform
Integration on Force.com Platform
 
REST APIs
REST APIsREST APIs
REST APIs
 
Api Design
Api DesignApi Design
Api Design
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 

Plus de kunal vishe

Plus de kunal vishe (20)

Mule data weave_10
Mule data weave_10Mule data weave_10
Mule data weave_10
 
Mule data weave_7
Mule data weave_7Mule data weave_7
Mule data weave_7
 
Mule data weave_8
Mule data weave_8Mule data weave_8
Mule data weave_8
 
Mule data weave_6
Mule data weave_6Mule data weave_6
Mule data weave_6
 
Mule data weave_5
Mule data weave_5Mule data weave_5
Mule data weave_5
 
Mule data weave_4
Mule data weave_4Mule data weave_4
Mule data weave_4
 
Mule data weave_3
Mule data weave_3Mule data weave_3
Mule data weave_3
 
Mule data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
 
Mule mel 5_tips
Mule mel 5_tipsMule mel 5_tips
Mule mel 5_tips
 
Mule mel 4_tips
Mule mel 4_tipsMule mel 4_tips
Mule mel 4_tips
 
Mule mel 3
Mule mel 3Mule mel 3
Mule mel 3
 
Mule mel 2
Mule mel 2Mule mel 2
Mule mel 2
 
Mule scopes request_response_scope
Mule scopes request_response_scopeMule scopes request_response_scope
Mule scopes request_response_scope
 
Mule scopes foreach_scope
Mule scopes foreach_scopeMule scopes foreach_scope
Mule scopes foreach_scope
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scope
 
Mule debugging logging_in_mule
Mule debugging logging_in_muleMule debugging logging_in_mule
Mule debugging logging_in_mule
 
Mule error handling_rollback exception strategy
Mule error handling_rollback exception strategyMule error handling_rollback exception strategy
Mule error handling_rollback exception strategy
 
Mule message
Mule messageMule message
Mule message
 
Mule error handling_choice exception strategy
Mule error handling_choice exception strategyMule error handling_choice exception strategy
Mule error handling_choice exception strategy
 
Mule concepts exception strategies
Mule concepts exception strategiesMule concepts exception strategies
Mule concepts exception strategies
 

Dernier

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Design API using RAML - basics

  • 1. RAML API Designing Basics Part 1
  • 2. • Introduction • RAML API Schema • Root • Resources • Methods • URI Parameters • Query Parameters • Responses
  • 3. • 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. Introduction
  • 4. • 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. Introduction
  • 5. 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
  • 6. • 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} Root
  • 7. 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:
  • 8. 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:
  • 9. 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
  • 10. 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:
  • 11. • 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 Query Parameters • To make a GET call, the URI looks like http://api.EmpolyeeDet.com/v1/ employees/ Thomas Anderson? employeeId =E001
  • 12. 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>

Notes de l'éditeur

  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 }
  3. /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 }
  4. /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 }