(Go: >> BACK << -|- >> HOME <<)

SlideShare a Scribd company logo
Design & Develop a REST API
with OpenAPI, Swagger, NodeJS
Luigi Saetta
Oracle Cloud Architect
1
REST API
• Everything is modeled as a RESOURCE
• Every resource is uniquely identified by a URI
• For example:
• /floor1/devices/dev1
• /floor1/lights/light1
• First of all, you want CRUD for RESOURCES (Create, Read, Update…)
• You use HTTP verbs to define the operations on resources
• GET: read the state
• POST: create a resource
• PUT: update the resource
• DELETE: the resource
2
Protocols
• Normally, a REST API is based on HTTP/HTTPS
• But, for example in the IoT World, you can have other protocols
• For example
• CoAP: Constrained Application Protocol, that is modeled after REST, but is a
binary (non Text) protocol based on UDP (not TCP as HTTP)
• In the constrained world of IoT devices HTTP is not always the best choice, is
too much verbose (bandwidth) and requires CPU (i.e.: battery power)
3
Discover and Describe an API
• Today, the emerging way for developing Systems and Applications is
MICROSERVICES
• An evolution of SOA
• You can develop the most beautiful API, but then you need to
document it for developers (of the clients)… and no-one wants to
write docs
• In SOA World Services were described using WSDL: a machine
readable language
• You were able to find endpoint for services and operations
• You were able to understand input parameters and response format
• You were able to generate clients with tools
4
Discover and Describe an API (2)
• Now, the most common way for an API is REST
• Over HTTP, usually the serialization format is JSON
• But, we still need a way to describe, document an API
• Maybe a way easier than WSDL and XML schema
• We need a way to discover what services are available, what
operations and what format for input and output
• Here, Swagger comes !
5
Swagger 101
• The idea is to describe a REST API in a Human and Machine Readable
Format
• You describe your API with a single file
• You can choose YAML
• You can use JSON
• The specification has been defined in a way that it is easy to develop
Open Source tools (and commercial tools)
• To parse Swagger descriptions
• To create server and client scaffold’s code from documentation
• To automatically generate documentation from code
• To generate a UI where you can access documentation and test API
6
Example of Swagger
2.0 documentation
for a REST API
7
OpenAPI
• Swagger 2.0 has been donated and has become Open API
• “Open API Initiative is focused on creating, evolving and promoting a
vendor neutral API Description Format based on the Swagger
Specification”
• https://www.openapis.org/
• The latest version of the spec can be found on GitHUB
• https://github.com/OAI/OpenAPI-Specification
8
Swagger Tools
9
Swagger Framework
• You can edit your swagger documentation file using Swagger Editor
• You can use the online version:
• http://editor.swagger.io/#/
• Or download it
• From the editor you can
• Generate server code
• Generate client code
10
Swagger UI
• It allows you to easily interact with your API
• It is auto-magically generated from your Swagger spec
• It enables you to see the operations available and to test it
11
Swagger and NodeJS
12
Swagger in NodeJS
• To install swagger tools and modules for Node
• npm install -g swagger
• To create the starting skeleton for a project
• swagger project create homeauto
• cd homeauto
• To start executing the API
• swagger project start
• To start editing the SWAGGER Yaml (in your browser)
• swagger project edit
13
Swagger Editor
14
API, swagger and IoT
15
API and IoT
• Scenario: a Home/Building Automation solution
• You need an Hub/Gateway, or a set of them
• Protocol translation (ZigBee, ZWAVE, Bluetooth)
• Message Broker (MQTT)
• Field Gateway towards IoT Cloud Service
• If you want to access from some applications functionalities and data
on the gateway you need a REST API
• I’m currently investigating the advantages of using Swagger to design
and develop the REST API
16
Swagger and Oracle
• Oracle API Catalog Cloud Service contains a list of API offered by SaaS
and PaaS services
• It can be freely accessed (no fee)
• For each API you can access the Swagger spec (in JSON)
• https://apicatalog.oraclecloud.com/ui/
• You can run NodeJS and swagger tools inside a Docker Container in
Oracle Container Cloud Service
17

More Related Content

What's hot

Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
Adam Paxton
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
Ivan Katunou
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
Tessa Mero
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
Aniruddh Bhilvare
 
Swagger With REST APIs.pptx.pdf
Swagger With REST APIs.pptx.pdfSwagger With REST APIs.pptx.pdf
Swagger With REST APIs.pptx.pdf
Knoldus Inc.
 
Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015
johannes_fiala
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
Ashok Pundit
 
Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014
JWORKS powered by Ordina
 
Api presentation
Api presentationApi presentation
Api presentation
Tiago Cardoso
 
Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)
Tony Tam
 
API Testing for everyone.pptx
API Testing for everyone.pptxAPI Testing for everyone.pptx
API Testing for everyone.pptx
Pricilla Bilavendran
 
Rest assured
Rest assuredRest assured
Rest assured
Varun Deshpande
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
Ankita Mahajan
 
Writing REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger AdaWriting REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger Ada
Stephane Carrez
 
Swagger - make your API accessible
Swagger - make your API accessibleSwagger - make your API accessible
Swagger - make your API accessible
Victor Trakhtenberg
 
코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes
코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes
코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes
Jiyeon Seo
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
123abcda
 
Api testing
Api testingApi testing
Api testing
HamzaMajid13
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
Nitin Pande
 
An introduction to api testing | David Tzemach
An introduction to api testing | David TzemachAn introduction to api testing | David Tzemach
An introduction to api testing | David Tzemach
David Tzemach
 

What's hot (20)

Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Swagger With REST APIs.pptx.pdf
Swagger With REST APIs.pptx.pdfSwagger With REST APIs.pptx.pdf
Swagger With REST APIs.pptx.pdf
 
Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014Documenting your REST API with Swagger - JOIN 2014
Documenting your REST API with Swagger - JOIN 2014
 
Api presentation
Api presentationApi presentation
Api presentation
 
Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)
 
API Testing for everyone.pptx
API Testing for everyone.pptxAPI Testing for everyone.pptx
API Testing for everyone.pptx
 
Rest assured
Rest assuredRest assured
Rest assured
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
Writing REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger AdaWriting REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger Ada
 
Swagger - make your API accessible
Swagger - make your API accessibleSwagger - make your API accessible
Swagger - make your API accessible
 
코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes
코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes
코드 리뷰의 또 다른 접근 방법: Pull Requests vs. Stacked Changes
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
Api testing
Api testingApi testing
Api testing
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
 
An introduction to api testing | David Tzemach
An introduction to api testing | David TzemachAn introduction to api testing | David Tzemach
An introduction to api testing | David Tzemach
 

Similar to Rest API with Swagger and NodeJS

Swagger: Restful documentation that won't put you to sleep
Swagger: Restful documentation that won't put you to sleepSwagger: Restful documentation that won't put you to sleep
Swagger: Restful documentation that won't put you to sleep
Tobias Coetzee
 
OpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsOpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red Hats
Mark Atwood
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's Rye
Cale Hoopes
 
Swagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierSwagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlier
Miroslav Resetar
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
Prem Sanil
 
Api fundamentals
Api fundamentalsApi fundamentals
Api fundamentals
AgileDenver
 
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM BluemixDeploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Arthur De Magalhaes
 
Get Your Node.js API Swaggering with OpenAPI Spec
Get Your Node.js API Swaggering with OpenAPI SpecGet Your Node.js API Swaggering with OpenAPI Spec
Get Your Node.js API Swaggering with OpenAPI Spec
Adam Paxton
 
Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017
JoEllen Carter
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
Domingo Suarez Torres
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidad
Software Guru
 
Free Mongo on OpenShift
Free Mongo on OpenShiftFree Mongo on OpenShift
Free Mongo on OpenShift
Steven Pousty
 
Eran Stiller: API design in the modern era - architecture next 2020
Eran Stiller: API design in the modern era - architecture next 2020 Eran Stiller: API design in the modern era - architecture next 2020
Eran Stiller: API design in the modern era - architecture next 2020
CodeValue
 
API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020
Eran Stiller
 
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Petko Mikhailov
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
Rasan Samarasinghe
 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)
Tom Johnson
 
API Description Languages: Which Is The Right One For Me?
 API Description Languages: Which Is The Right One For Me?  API Description Languages: Which Is The Right One For Me?
API Description Languages: Which Is The Right One For Me?
ProgrammableWeb
 
Using the Splunk Java SDK
Using the Splunk Java SDKUsing the Splunk Java SDK
Using the Splunk Java SDK
Damien Dallimore
 
API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?
Akana
 

Similar to Rest API with Swagger and NodeJS (20)

Swagger: Restful documentation that won't put you to sleep
Swagger: Restful documentation that won't put you to sleepSwagger: Restful documentation that won't put you to sleep
Swagger: Restful documentation that won't put you to sleep
 
OpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsOpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red Hats
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's Rye
 
Swagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierSwagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlier
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
Api fundamentals
Api fundamentalsApi fundamentals
Api fundamentals
 
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM BluemixDeploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
 
Get Your Node.js API Swaggering with OpenAPI Spec
Get Your Node.js API Swaggering with OpenAPI SpecGet Your Node.js API Swaggering with OpenAPI Spec
Get Your Node.js API Swaggering with OpenAPI Spec
 
Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidad
 
Free Mongo on OpenShift
Free Mongo on OpenShiftFree Mongo on OpenShift
Free Mongo on OpenShift
 
Eran Stiller: API design in the modern era - architecture next 2020
Eran Stiller: API design in the modern era - architecture next 2020 Eran Stiller: API design in the modern era - architecture next 2020
Eran Stiller: API design in the modern era - architecture next 2020
 
API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020
 
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)
 
API Description Languages: Which Is The Right One For Me?
 API Description Languages: Which Is The Right One For Me?  API Description Languages: Which Is The Right One For Me?
API Description Languages: Which Is The Right One For Me?
 
Using the Splunk Java SDK
Using the Splunk Java SDKUsing the Splunk Java SDK
Using the Splunk Java SDK
 
API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?
 

Recently uploaded

@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Misti Soneji
 
AI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdfAI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdf
ayushiqss
 
Design system: The basis for a consistent design
Design system: The basis for a consistent designDesign system: The basis for a consistent design
Design system: The basis for a consistent design
Ortus Solutions, Corp
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
Ortus Solutions, Corp
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Asher Sterkin
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
e-Definers Technology
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
shivamt017
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Sparity1
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
DNUG e.V.
 
Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?
Ortus Solutions, Corp
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
YouTube SEO Mastery ......................
YouTube SEO Mastery ......................YouTube SEO Mastery ......................
YouTube SEO Mastery ......................
islamiato717
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
confluent
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
Ortus Solutions, Corp
 
BoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and DebuggerBoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and Debugger
Ortus Solutions, Corp
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Panvel @Call @Girls Whatsapp 9833363713 With High Profile Offer
Panvel @Call @Girls Whatsapp 9833363713 With High Profile OfferPanvel @Call @Girls Whatsapp 9833363713 With High Profile Offer
Panvel @Call @Girls Whatsapp 9833363713 With High Profile Offer
$A19
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
AUGNYC
 

Recently uploaded (20)

@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
AI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdfAI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdf
 
Design system: The basis for a consistent design
Design system: The basis for a consistent designDesign system: The basis for a consistent design
Design system: The basis for a consistent design
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
 
Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
YouTube SEO Mastery ......................
YouTube SEO Mastery ......................YouTube SEO Mastery ......................
YouTube SEO Mastery ......................
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
 
BoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and DebuggerBoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and Debugger
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
 
Panvel @Call @Girls Whatsapp 9833363713 With High Profile Offer
Panvel @Call @Girls Whatsapp 9833363713 With High Profile OfferPanvel @Call @Girls Whatsapp 9833363713 With High Profile Offer
Panvel @Call @Girls Whatsapp 9833363713 With High Profile Offer
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
 

Rest API with Swagger and NodeJS

  • 1. Design & Develop a REST API with OpenAPI, Swagger, NodeJS Luigi Saetta Oracle Cloud Architect 1
  • 2. REST API • Everything is modeled as a RESOURCE • Every resource is uniquely identified by a URI • For example: • /floor1/devices/dev1 • /floor1/lights/light1 • First of all, you want CRUD for RESOURCES (Create, Read, Update…) • You use HTTP verbs to define the operations on resources • GET: read the state • POST: create a resource • PUT: update the resource • DELETE: the resource 2
  • 3. Protocols • Normally, a REST API is based on HTTP/HTTPS • But, for example in the IoT World, you can have other protocols • For example • CoAP: Constrained Application Protocol, that is modeled after REST, but is a binary (non Text) protocol based on UDP (not TCP as HTTP) • In the constrained world of IoT devices HTTP is not always the best choice, is too much verbose (bandwidth) and requires CPU (i.e.: battery power) 3
  • 4. Discover and Describe an API • Today, the emerging way for developing Systems and Applications is MICROSERVICES • An evolution of SOA • You can develop the most beautiful API, but then you need to document it for developers (of the clients)… and no-one wants to write docs • In SOA World Services were described using WSDL: a machine readable language • You were able to find endpoint for services and operations • You were able to understand input parameters and response format • You were able to generate clients with tools 4
  • 5. Discover and Describe an API (2) • Now, the most common way for an API is REST • Over HTTP, usually the serialization format is JSON • But, we still need a way to describe, document an API • Maybe a way easier than WSDL and XML schema • We need a way to discover what services are available, what operations and what format for input and output • Here, Swagger comes ! 5
  • 6. Swagger 101 • The idea is to describe a REST API in a Human and Machine Readable Format • You describe your API with a single file • You can choose YAML • You can use JSON • The specification has been defined in a way that it is easy to develop Open Source tools (and commercial tools) • To parse Swagger descriptions • To create server and client scaffold’s code from documentation • To automatically generate documentation from code • To generate a UI where you can access documentation and test API 6
  • 7. Example of Swagger 2.0 documentation for a REST API 7
  • 8. OpenAPI • Swagger 2.0 has been donated and has become Open API • “Open API Initiative is focused on creating, evolving and promoting a vendor neutral API Description Format based on the Swagger Specification” • https://www.openapis.org/ • The latest version of the spec can be found on GitHUB • https://github.com/OAI/OpenAPI-Specification 8
  • 10. Swagger Framework • You can edit your swagger documentation file using Swagger Editor • You can use the online version: • http://editor.swagger.io/#/ • Or download it • From the editor you can • Generate server code • Generate client code 10
  • 11. Swagger UI • It allows you to easily interact with your API • It is auto-magically generated from your Swagger spec • It enables you to see the operations available and to test it 11
  • 13. Swagger in NodeJS • To install swagger tools and modules for Node • npm install -g swagger • To create the starting skeleton for a project • swagger project create homeauto • cd homeauto • To start executing the API • swagger project start • To start editing the SWAGGER Yaml (in your browser) • swagger project edit 13
  • 16. API and IoT • Scenario: a Home/Building Automation solution • You need an Hub/Gateway, or a set of them • Protocol translation (ZigBee, ZWAVE, Bluetooth) • Message Broker (MQTT) • Field Gateway towards IoT Cloud Service • If you want to access from some applications functionalities and data on the gateway you need a REST API • I’m currently investigating the advantages of using Swagger to design and develop the REST API 16
  • 17. Swagger and Oracle • Oracle API Catalog Cloud Service contains a list of API offered by SaaS and PaaS services • It can be freely accessed (no fee) • For each API you can access the Swagger spec (in JSON) • https://apicatalog.oraclecloud.com/ui/ • You can run NodeJS and swagger tools inside a Docker Container in Oracle Container Cloud Service 17