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

  1. Click on the + Add button and select New API.

  2. 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

  3. 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.

  4. 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.

  5. Click the + icon in the Definitions section to create a new definition. Then, click on new-definitions-1 to edit the new definition.

  6. Edit the Name of the definition, set it to paymentAmount. Leave the definition Type set to object.

  7. 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

  8. Now that you have a definition, you need to create a path to attach it to. Click on Paths from the API Designer menu.

  9. 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.

  10. Edit the default path location to be /calculate.

  11. Click on the GET /calculate operation to expand its configuration options.

  12. 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.

    Click on the Add Parameter link to create a new query parameter. Then, select Add new parameter from the sub-menu.

  13. 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.

  14. 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

  15. 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.

  16. 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.