SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
Build REST APIs using Swagger and IBM Integration Bus – IIB v10
Installing Swagger locally
1. Install NodeJS
a. Choose the appropriate installer from https://nodejs.org/download/
2. git clone https://github.com/swagger-api/swagger-editor.git
3. cd swagger-editor
4. npm start
Note for 3. You will find the Swagger-editor in thebelow location in Windows
C:Users{UserName}DocumentsGitHubswagger-editor
Once Swagger Editor starts locally it will open the Editor in the below location
http://localhost:8080/#/
The browserbased swagger editor is available in the internet at
http://editor.swagger.io/#/
Swagger API Specification can be found here
https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md
Create a Simple Rest API Definition in Swagger
Below is a simple REST API named Payment API. The Payment API will enable customers to view all
scheduled payments for a Customer and post payments to different accounts setup for bill pay.
The goal here is to just show how to define a REST API using Swagger as use it for development in IIB
v10. I will cover how to model REST APIs using RAML in a different post.
Below is the Payment API Swagger definition. Swagger definitions are in YAML format.
swagger: '2.0'
info:
version: '1.0.0'
title: Payment API
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
description: The Payment API enables customers to retrieve about all scheduled payments & post payments
termsOfService: http://wwww.ibmdeveloper.com/terms/
contact:
name: API Management Team
email: juliansmiles@ibmdeveloper.com
url: http://www.ibmdeveloper.com
license:
name: MIT
url: http://opensource.org/licenses/MIT
host: ibmdeveloper.com
basePath: /billpay
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/payments/{customerId}:
get:
description: Returns all Payments that are scheduled for a customer
operationId: findPayments
produces:
- application/json
- application/xml
- text/xml
- text/html
parameters:
- name: customerId
in: path
type: string
description: ID of the Customer
required: true
responses:
'200':
description: scheduled payments response
schema:
type: array
items:
$ref: '#/definitions/payments'
default:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
post:
description: Schedule/Post a new payment
operationId: postPayment
produces:
- application/json
parameters:
- name: customerId
in: path
type: string
description: ID of the Customer
required: true
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
- in: formData
name: paymentAmount
description: Payment Amount to be posted
required: true
type: number
format: float
- in: formData
name: paymentDate
description: Payment Date
required: true
type: string
- in: formData
name: paymentAccount
description: Account where payment is to be posted
required: true
type: string
responses:
'200':
description: payment response
schema:
$ref: '#/definitions/paymentId'
default:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
definitions:
payments:
required:
- paymentId
- paymentAccount
- paymentDate
properties:
paymentId:
$ref: '#/definitions/paymentId'
paymentAccount:
type: string
paymentDate:
type: string
tag:
type: string
paymentId:
type: integer
format: int64
errorModel:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
IIB v10 expects the definitionto be in JSON format. The Swagger editor provides theoption to save the
file in JSON format.
The Payment API has 2 methods, GET and POST
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
The GET method will retrieve all the payments that are scheduled for a Customer. The Customer Id is
the key that identifies a specific customer.
The POST method enables a customer to post/schedule payments to a specific bill pay account.
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
Below are the message models / response message formats.
The errorModel defines a generic error message format for any errors.
The response to the POST is a paymentId.
The response to the GET is the payments structure, which returns the paymentAccount, paymentDate
& paymentId
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
REST API Implementation using Integration Bus - IIBv10
Choose New -> Start by creating a REST API
Specify the nameof the REST API
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
Select the PaymentAPI.json file we downloaded earlier from the Swagger Editor
Review the API definition
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
Once the import is successful, the API description and sample message flows arecreated like below.
Below is the IIB generated Payment_API.msgflow. The default message domain as you cansee below is
JSON.
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
Below is the REST API description inside the toolkit.
Choose ‘Implement theoperation’ next to both
This will create a sub-flow for each operation i.e. one for GET and one for POST. Below is the sub-flow
for the GET operation. The name of the sub-flow reflects the operationId in the API definition.
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
Before we complete the entire implementation, I would like to deploy theAPI to make sure we can
invoke theAPI.
To test the API, I usePostman which is great for REST API testing. There are many other tools available
and you can use the tool of your choice. Postman is available in the Chrome App Store.
Right Click on the Payment API and deploy it to an integration server. Once it is deployed, you should
be able to see the properties like below.
It shows you the URL you need to invoke.
Let’s try to invoke the above URL using Postman
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
This returns a 404 as the API does not support base URL invocation. The right URL should bebaseURL
+ /billpay/{customerId}
Let’s change the URL to http://localhost:7800/billpay/payments/1212
This returns a 501 as we haven’t completed the sub-flow implementations yet.
Now that wecan invoke the API, let’s moveon to complete the message flows.
Let’s add a Compute Node to both the sub-flows and leave the ESQL code like below, deploy and test
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
When you try to test GET operation now, you a 200 Status code. But the responseis empty as we
haven’t implemented any code to return as valid JSON response.
Let’s make some changes to the above ESQL to return a valid response.
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
I have just hardcoded the values as our goal is to just build a basic API. I haven’t shown how to integrate
with a backend etc. for a comprehensive implementation as it is beyond the scope of what I am trying
to demonstrate here.
Now let’s try to invokethe URL again for GET
Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles
juliansmiles@ibmdeveloper.com
Now you get a valid JSON response.
You can try your POST operation similarly
Here is the representation of the JSON message tree in the debugger for the POST
I hope this information was useful to you.

Mais conteúdo relacionado

Mais procurados

Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...
Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...
Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...Orkhan Gasimov
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Maarten Mulders
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API GatewayYohann Ciurlik
 
Kuberntes Ingress with Kong
Kuberntes Ingress with KongKuberntes Ingress with Kong
Kuberntes Ingress with KongNebulaworks
 
Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways Kong Inc.
 
What is an API Gateway?
What is an API Gateway?What is an API Gateway?
What is an API Gateway?LunchBadger
 
Gatekeeper: API gateway
Gatekeeper: API gatewayGatekeeper: API gateway
Gatekeeper: API gatewayChengHui Weng
 
21st Docker Switzerland Meetup - ISTIO
21st Docker Switzerland Meetup - ISTIO21st Docker Switzerland Meetup - ISTIO
21st Docker Switzerland Meetup - ISTIONiklaus Hirt
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinGavin Pickin
 
Going MicroServices with Net
Going MicroServices with NetGoing MicroServices with Net
Going MicroServices with NetDavid Revoledo
 
Comprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioComprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioFred Moyer
 
Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...
Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...
Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...Daniel Oh
 
Cloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudCloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudConor Svensson
 
The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)Geekstone
 
Connecting All Abstractions with Istio
Connecting All Abstractions with IstioConnecting All Abstractions with Istio
Connecting All Abstractions with IstioVMware Tanzu
 
Building a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istioBuilding a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istioSAMIR BEHARA
 
Real time websites and mobile apps with SignalR
Real time websites and mobile apps with SignalRReal time websites and mobile apps with SignalR
Real time websites and mobile apps with SignalRRoy Cornelissen
 
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...VMware Tanzu
 

Mais procurados (20)

Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...
Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...
Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...
 
Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)Mastering Microservices with Kong (DevoxxUK 2019)
Mastering Microservices with Kong (DevoxxUK 2019)
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API Gateway
 
Kuberntes Ingress with Kong
Kuberntes Ingress with KongKuberntes Ingress with Kong
Kuberntes Ingress with Kong
 
Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
 
What is an API Gateway?
What is an API Gateway?What is an API Gateway?
What is an API Gateway?
 
Gatekeeper: API gateway
Gatekeeper: API gatewayGatekeeper: API gateway
Gatekeeper: API gateway
 
21st Docker Switzerland Meetup - ISTIO
21st Docker Switzerland Meetup - ISTIO21st Docker Switzerland Meetup - ISTIO
21st Docker Switzerland Meetup - ISTIO
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin Pickin
 
Kong
KongKong
Kong
 
Going MicroServices with Net
Going MicroServices with NetGoing MicroServices with Net
Going MicroServices with Net
 
Comprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioComprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istio
 
Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...
Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...
Microservice 4.0 Journey - From Spring NetFlix OSS to Istio Service Mesh and ...
 
Cloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudCloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring Cloud
 
The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)
 
API Gateway study
API Gateway studyAPI Gateway study
API Gateway study
 
Connecting All Abstractions with Istio
Connecting All Abstractions with IstioConnecting All Abstractions with Istio
Connecting All Abstractions with Istio
 
Building a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istioBuilding a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istio
 
Real time websites and mobile apps with SignalR
Real time websites and mobile apps with SignalRReal time websites and mobile apps with SignalR
Real time websites and mobile apps with SignalR
 
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud - An...
 

Semelhante a Build REST API's using Swagger and IBM Integration Bus IIB v10

Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015johannes_fiala
 
Play Your API with MuleSoft API Notebook
Play Your API with MuleSoft API NotebookPlay Your API with MuleSoft API Notebook
Play Your API with MuleSoft API NotebookRakesh Kumar Jha
 
アプリで簡単にスタンプを販売するためのAPI開発
アプリで簡単にスタンプを販売するためのAPI開発アプリで簡単にスタンプを販売するためのAPI開発
アプリで簡単にスタンプを販売するためのAPI開発LINE Corporation
 
Z101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apisZ101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apisTeodoro Cipresso
 
Learn how to use API with 2 API examples.pdf
Learn how to use API with 2 API examples.pdfLearn how to use API with 2 API examples.pdf
Learn how to use API with 2 API examples.pdfBe Problem Solver
 
AWS Step Function with API Gateway Integration - Metin Kale, Chicago
AWS Step Function with API Gateway Integration - Metin Kale, ChicagoAWS Step Function with API Gateway Integration - Metin Kale, Chicago
AWS Step Function with API Gateway Integration - Metin Kale, ChicagoAWS Chicago
 
Creating asynchronous flows on AWS
Creating asynchronous flows on AWSCreating asynchronous flows on AWS
Creating asynchronous flows on AWSMetin Kale
 
Into The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sInto The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sOrtus Solutions, Corp
 
java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guideZenita Smythe
 
Microsoft identity platform and device authorization flow to use azure servic...
Microsoft identity platform and device authorization flow to use azure servic...Microsoft identity platform and device authorization flow to use azure servic...
Microsoft identity platform and device authorization flow to use azure servic...Sunil kumar Mohanty
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsTom Johnson
 
Line Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootLine Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootInnovationM
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.jsDev_Events
 
Building Scalable Services with Amazon API Gateway - Technical 201
Building Scalable Services with Amazon API Gateway - Technical 201Building Scalable Services with Amazon API Gateway - Technical 201
Building Scalable Services with Amazon API Gateway - Technical 201Amazon Web Services
 
Azure APIM Presentation to understand about.pptx
Azure APIM Presentation to understand about.pptxAzure APIM Presentation to understand about.pptx
Azure APIM Presentation to understand about.pptxpythagorus143
 
Serverless Design Patterns
Serverless Design PatternsServerless Design Patterns
Serverless Design PatternsYan Cui
 
Serveless design patterns (VoxxedDays Luxembourg)
Serveless design patterns (VoxxedDays Luxembourg)Serveless design patterns (VoxxedDays Luxembourg)
Serveless design patterns (VoxxedDays Luxembourg)Yan Cui
 
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way
 AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless WaySrushith Repakula
 
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...CodeOps Technologies LLP
 

Semelhante a Build REST API's using Swagger and IBM Integration Bus IIB v10 (20)

Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015Rest api code completion for javascript - dotjs 2015
Rest api code completion for javascript - dotjs 2015
 
Play Your API with MuleSoft API Notebook
Play Your API with MuleSoft API NotebookPlay Your API with MuleSoft API Notebook
Play Your API with MuleSoft API Notebook
 
アプリで簡単にスタンプを販売するためのAPI開発
アプリで簡単にスタンプを販売するためのAPI開発アプリで簡単にスタンプを販売するためのAPI開発
アプリで簡単にスタンプを販売するためのAPI開発
 
Z101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apisZ101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apis
 
Learn how to use API with 2 API examples.pdf
Learn how to use API with 2 API examples.pdfLearn how to use API with 2 API examples.pdf
Learn how to use API with 2 API examples.pdf
 
AWS Step Function with API Gateway Integration - Metin Kale, Chicago
AWS Step Function with API Gateway Integration - Metin Kale, ChicagoAWS Step Function with API Gateway Integration - Metin Kale, Chicago
AWS Step Function with API Gateway Integration - Metin Kale, Chicago
 
Creating asynchronous flows on AWS
Creating asynchronous flows on AWSCreating asynchronous flows on AWS
Creating asynchronous flows on AWS
 
Into The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sInto The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api's
 
java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guide
 
Microsoft identity platform and device authorization flow to use azure servic...
Microsoft identity platform and device authorization flow to use azure servic...Microsoft identity platform and device authorization flow to use azure servic...
Microsoft identity platform and device authorization flow to use azure servic...
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
Line Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootLine Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-Boot
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
 
Building Scalable Services with Amazon API Gateway - Technical 201
Building Scalable Services with Amazon API Gateway - Technical 201Building Scalable Services with Amazon API Gateway - Technical 201
Building Scalable Services with Amazon API Gateway - Technical 201
 
Azure APIM Presentation to understand about.pptx
Azure APIM Presentation to understand about.pptxAzure APIM Presentation to understand about.pptx
Azure APIM Presentation to understand about.pptx
 
Serverless Design Patterns
Serverless Design PatternsServerless Design Patterns
Serverless Design Patterns
 
Serveless design patterns (VoxxedDays Luxembourg)
Serveless design patterns (VoxxedDays Luxembourg)Serveless design patterns (VoxxedDays Luxembourg)
Serveless design patterns (VoxxedDays Luxembourg)
 
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way
 AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way
 
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless W...
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 

Último

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Build REST API's using Swagger and IBM Integration Bus IIB v10

  • 1. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com Build REST APIs using Swagger and IBM Integration Bus – IIB v10 Installing Swagger locally 1. Install NodeJS a. Choose the appropriate installer from https://nodejs.org/download/ 2. git clone https://github.com/swagger-api/swagger-editor.git 3. cd swagger-editor 4. npm start Note for 3. You will find the Swagger-editor in thebelow location in Windows C:Users{UserName}DocumentsGitHubswagger-editor Once Swagger Editor starts locally it will open the Editor in the below location http://localhost:8080/#/ The browserbased swagger editor is available in the internet at http://editor.swagger.io/#/ Swagger API Specification can be found here https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md Create a Simple Rest API Definition in Swagger Below is a simple REST API named Payment API. The Payment API will enable customers to view all scheduled payments for a Customer and post payments to different accounts setup for bill pay. The goal here is to just show how to define a REST API using Swagger as use it for development in IIB v10. I will cover how to model REST APIs using RAML in a different post. Below is the Payment API Swagger definition. Swagger definitions are in YAML format. swagger: '2.0' info: version: '1.0.0' title: Payment API
  • 2. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com description: The Payment API enables customers to retrieve about all scheduled payments & post payments termsOfService: http://wwww.ibmdeveloper.com/terms/ contact: name: API Management Team email: juliansmiles@ibmdeveloper.com url: http://www.ibmdeveloper.com license: name: MIT url: http://opensource.org/licenses/MIT host: ibmdeveloper.com basePath: /billpay schemes: - http consumes: - application/json produces: - application/json paths: /payments/{customerId}: get: description: Returns all Payments that are scheduled for a customer operationId: findPayments produces: - application/json - application/xml - text/xml - text/html parameters: - name: customerId in: path type: string description: ID of the Customer required: true responses: '200': description: scheduled payments response schema: type: array items: $ref: '#/definitions/payments' default: description: unexpected error schema: $ref: '#/definitions/errorModel' post: description: Schedule/Post a new payment operationId: postPayment produces: - application/json parameters: - name: customerId in: path type: string description: ID of the Customer required: true
  • 3. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com - in: formData name: paymentAmount description: Payment Amount to be posted required: true type: number format: float - in: formData name: paymentDate description: Payment Date required: true type: string - in: formData name: paymentAccount description: Account where payment is to be posted required: true type: string responses: '200': description: payment response schema: $ref: '#/definitions/paymentId' default: description: unexpected error schema: $ref: '#/definitions/errorModel' definitions: payments: required: - paymentId - paymentAccount - paymentDate properties: paymentId: $ref: '#/definitions/paymentId' paymentAccount: type: string paymentDate: type: string tag: type: string paymentId: type: integer format: int64 errorModel: required: - code - message properties: code: type: integer format: int32 message: type: string
  • 4. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com IIB v10 expects the definitionto be in JSON format. The Swagger editor provides theoption to save the file in JSON format. The Payment API has 2 methods, GET and POST
  • 5. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com The GET method will retrieve all the payments that are scheduled for a Customer. The Customer Id is the key that identifies a specific customer. The POST method enables a customer to post/schedule payments to a specific bill pay account.
  • 6. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com Below are the message models / response message formats. The errorModel defines a generic error message format for any errors. The response to the POST is a paymentId. The response to the GET is the payments structure, which returns the paymentAccount, paymentDate & paymentId
  • 7. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com REST API Implementation using Integration Bus - IIBv10 Choose New -> Start by creating a REST API Specify the nameof the REST API
  • 8. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com Select the PaymentAPI.json file we downloaded earlier from the Swagger Editor Review the API definition
  • 9. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com Once the import is successful, the API description and sample message flows arecreated like below. Below is the IIB generated Payment_API.msgflow. The default message domain as you cansee below is JSON.
  • 10. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com Below is the REST API description inside the toolkit. Choose ‘Implement theoperation’ next to both This will create a sub-flow for each operation i.e. one for GET and one for POST. Below is the sub-flow for the GET operation. The name of the sub-flow reflects the operationId in the API definition.
  • 11. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com Before we complete the entire implementation, I would like to deploy theAPI to make sure we can invoke theAPI. To test the API, I usePostman which is great for REST API testing. There are many other tools available and you can use the tool of your choice. Postman is available in the Chrome App Store. Right Click on the Payment API and deploy it to an integration server. Once it is deployed, you should be able to see the properties like below. It shows you the URL you need to invoke. Let’s try to invoke the above URL using Postman
  • 12. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com This returns a 404 as the API does not support base URL invocation. The right URL should bebaseURL + /billpay/{customerId} Let’s change the URL to http://localhost:7800/billpay/payments/1212 This returns a 501 as we haven’t completed the sub-flow implementations yet. Now that wecan invoke the API, let’s moveon to complete the message flows. Let’s add a Compute Node to both the sub-flows and leave the ESQL code like below, deploy and test
  • 13. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com When you try to test GET operation now, you a 200 Status code. But the responseis empty as we haven’t implemented any code to return as valid JSON response. Let’s make some changes to the above ESQL to return a valid response.
  • 14. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com I have just hardcoded the values as our goal is to just build a basic API. I haven’t shown how to integrate with a backend etc. for a comprehensive implementation as it is beyond the scope of what I am trying to demonstrate here. Now let’s try to invokethe URL again for GET
  • 15. Build REST APIs using Swagger and IBM Integration Bus – IIB v10 | Julian Smiles juliansmiles@ibmdeveloper.com Now you get a valid JSON response. You can try your POST operation similarly Here is the representation of the JSON message tree in the debugger for the POST I hope this information was useful to you.