REST API using Swagger
• IBM Integration Bus supports version 2.0 of the Swagger specification
• By using swagger we can create REST API in IBM Integration Bus, we can import a Swagger document by using the IBM Integration Toolkit
• Swagger is an open specification for defining REST API it is same like wsdl for SOAP based service
• It must be json format (.json) or yaml format (.Yaml).this document specifies the list of resources that are available in REST API
• It also specifies the parameters to an operation including name and type of the parameters
• It includes the structure of request body that is sent to an operation in a REST API and The structure of any response bodies that are returned from an operation
• The copy of Swagger document is available in installation path (C:\Program Files\IBM\IIB\10.0.0.12\server\sample\restapis\swagger. Json)
Procedure for creating REST API with swagger document:
• We have to Click File > New> REST API
• We have to enter a name for the REST API, it is name is our project
• We have to select Import resources and operations defined in a Swagger document click next.
• After that Select the path to the Swagger document that describes the resources and operation in the REST API.
• We have import swagger document from the file system or from an existing project in the workspace.
• While importing swagger document file is validated for use in a REST API. If any errors are found while the selected swagger document is validated, those validation errors are displayed at the top of the wizard.
We cannot proceed if validation errors are found in the selected Swagger document.
• If we did not get any errors the document success fully imported click Finish.
• REST API message flow created automatically
The following are advantages of the Swagger Framework:
• It Synchronizes the API document with the server and client in the same step.
• We can generate REST API documentation and interact with the REST API.
• Interaction swagger UI Framework gives clear understanding about how the API responds to parameters.
• Response will be in the format of JSON and XML.
• It can implement in the various technologies, such as Java, iib and HTML5.
The REST API is created by using swagger after importing swagger document it automatically generated message flow its operations.