Home - Kaributechs/ibm-api-connect GitHub Wiki
Create the Financing API (REST to SOAP) API Developer ThinkIBM wants to give their customers the ability to calculate financing payments. There is already a legacy SOAP-based application which will do the calculation, but it should be exposed to consumers as a modern RESTful API.
In this section, you will create a new OpenAPI definition for the financing API. Create the API Definition
Click on the + Add button and select New API. Fill in the form values for the API, then click the Create API button to continue. Title: financing Name: financing Base Path: /financing Version: 1.0.0 API Connect will generate a new OpenAPI definition file for the financing API and automatically load the API editor screen. Notice that the API does not contain any paths or data definitions. We will be adding these in the following steps. Next, we need to create the model definition for our new API. These definitions are used in a few places. Their primary role is to serve as documentation in the developer portal on expected input and output parameters; however, they can also be used for data mapping actions. Click on Definitions from the API Designer menu. Click the + icon in the Definitions section to create a new definition. Then, click on new-definitions-1 to edit the new definition. Edit the Name of the definition, set it to paymentAmount. Leave the definition Type set to object. Scroll down to the definition Properties section. The new definition already adds in a sample property called new-property-1. Edit the property values: Property Name: paymentAmount Description: Monthly payment amount Type: float Example: 199.99 Now that you have a definition, you need to create a path to attach it to. Click on Paths from the API Designer menu. Click on the + button to create a new path. The template will generate the path and a GET operation under the path. This is sufficient for our needs, but we could also add other operations and REST verbs to our path if needed. Edit the default path location to be /calculate. Note: Recall that our Base Path for this API is /financing. This new path will be appended to the base, creating a final path of /financing/calculate. Click on the GET /calculate operation to expand its configuration options. Next, you have the option of adding request parameters to the operation. This defines the input to the API request. Since this is a GET request, add the required request parameters to the query component of the URI. Scroll down and find the Parameters section within the operation config. Note: There are two Parameters sections. The top level section is for PATH parameters and would apply to all operations under the path. There is also a Parameters section for each operation. For this section, please use the parameters in the GET operation section. Click on the Add Parameter link to create a new query parameter. Then, select Add new parameter from the sub-menu. You are actually going to need three total parameters for this operation, so go ahead and click on the Add Parameter link two more times to add the parameter templates. Edit the parameters to set the values: Name Located In Description Required Type amount Query amount to finance yes number-float duration Query length of term in months yes integer-32 rate Query interest rate yes number-float Set the schema for the response. Since we already defined the paymentAmount definition, we will select it from the drop down list. You will find the paymentAmount definition at the top of the list. Save the API definition.
Continue
So far in this lab, you have built an API Definition which provides details to consumers on how to make an API request and what to expect as a response.
In the next step, you will create an API Assembly configuration which maps the REST calls into SOAP, and SOAP responses into JSON.
Proceed to Map the API to a Service WSDL.