5. API Economy
• APIs connect services in the Internet-of-things (IoT).
• Businesses provide and consume assets through APIs.
• REST APIs are client and server neutral, so often used as the bridge in
IoT.
• The number of available REST APIs increases daily, but without a
standard way of defining, exposing or discovering them.
4
7. Swagger Introduction
• Industry leading specification for defining REST APIs.
• Supports with both JSON and YAML formats.
• Large open source community with various projects on GitHub:
• Client code generation (26 languages).
• Server code generation (9 languages).
• Online editor and GUI.
• Over 2000 related open-source repository, with 15000 daily downloads.
• Base specification for Open API Initiative (https://openapis.org/), under
Linux foundation.
6
8. Swagger YAML Sample
7
paths:
/pet:
post:
tags:
- pet
summary: Add a new pet to the store
description: ''
operationId: addPet
consumes:
- application/json
- application/xml
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: Pet object that needs to be added to the store
required: true
schema:
$ref: '#/definitions/Pet'
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
10. StrongLoop (an IBM Company)
• Leader in enterprise Node.js.
• Over 130 npm modules.
• Major contributor to Open Source LoopBack and Express.
• Design REST APIs from data models.
• Top-down from design or from Swagger doc.
• Auto-generates Swagger 2.0
• Core member of Node.js Foundation.
• Available as part of API Connect’s “Create” license
9
18. API Economy with Liberty
• What are the challenges when using Swagger with Java EE?
– Merging Swagger from annotations and standalone docs
– UI for rapid API development and unit testing
– Exploring all available APIs
– Generating code to call external services
• Liberty can help with all of these things!
17
19. API Discovery
• All applications are discoverable in a single RESTful endpoint,
/ibm/api/docs
• Query parameter allows filtering based on context root.
• Support both JSON and YAML.
• Application participation can be configured in server.xml (location, on/off).
• Available through apiDiscovery-1.0 feature.
18
Applications
Liberty
REST
Admin UI
API Connect
20. API Discovery User Interface
• Based on the Open Source Swagger UI.
• Available at /ibm/api/explorer.
19
21. API Discovery Collective Support
• Enabling apiDiscovery-1.0 on a collective member will expose their
aggregated Swagger documentation available.
• Endpoints:
– /ibm/api/collective/docs
– /ibm/api/collective/explorer
20
Admin UI
Repository
membersREST
controller
API Connect
22. API Discovery Subscription
• POST ibm/api/docs/subscription
• Request:
{ docType: string}
• Returns:
{ feedURL : wss://ibm/api/docs/subscription/websocket/{id}, feedType: websocket }
• The client opens WSS connection and receives updates in real-time
• Equivalent collective support at /ibm/api/collective/docs/subscription
• Works with either webSocket-1.0 or webSocket-1.1
21
23. API Discovery in Bluemix
• Push a Liberty package into Bluemix
• cf push <yourappname> -p defaultServer
• Creates an auto-discoverable container in the cloud.
22
Admin UI
app
app
app
WLP
API Connect
24. C
M
M
Pulling Liberty Assets from API Connect
23
API Connect
Hybrid Liberty + StrongLoop Collective
swagger.json
25. Pushing Standalone Assets into API Connect
Continuous Integration
product.json
Source Repository
Swagger
processor
API Connect
CLI
PUBLIC | DEDICATED | LOCAL
API Connectproduct.json +
swagger.json
Developer
26. Pushing Liberty Assets into API Connect
Hybrid Liberty + StrongLoop Collective
PUBLIC | DEDICATED | LOCAL
API Connect
Administrator
product.json
product.json
C
M
M
or
product.json +
swagger.json
Developer
Continuous Integration
deploy
1
2
27. WebSphere Developer Tools Support
• Authoring Swagger document (main doc or stub) through templates
and skeleton
• Includes JSON and Swagger-based validation.
• Auto-generate JAXRS 2.0 client from Swagger document or URL
• Can point to a running Liberty instance or Collective Controller and generate a
JAXRS client that can connect to any of the exposed services!
26