Adding a Front-End API for API Customization

TIBCO Cloud Integration - Microflow® provides the functionality to expose a customized front-end API to a specific group of users based on a generic back-end API. The back end is the source of truth for the business logic of your service. It defines the behavior of your service; while, the front end delivers the APIs customized for specific groups of users. Microflow achieves this by linking the front-end specification to the back-end specification.

Using this Backend-for-Frontend pattern, you can easily derive multiple services from a back-end application without any code effort.

For example, a shop hosts a service that sells all sorts of things. In order to maximize its marketing, the shop decides to create APIs specific to a certain type of items such as books or movies. Instead of creating multiple integration applications which are very costly, the shop decides to build specific APIs for each of those items that in the end call the same integration application. Each Microflow application exposes a different front-end API and transforms the requests of all sorts into the generic format to send to the back-end integration application.

The following tutorial shows how to create a Cat service by modifying one API operation from the existing Petstore service:

  1. On the Apps page, click the default application, petstore_sample_microflow.
  2. On the Application Details page, click the Implementation tab and then click Edit.

    The Microflow page is displayed. A set of stages are added to the sample.

  3. In the left Operations section, click Frontend API > Import to import the front-end API specification.

    You can model your Cat service in TIBCO® Cloud Integration - API Modeler based on the existing Petstore API specification, and then export the Cat API specification in the Swagger JSON format. This Cat API specification is used as the front-end specification in this tutorial.

    Swagger Specification Reference is a copy of the Cat Swagger specification.

    Note: The API specification must be a Swagger specification.

  4. Click Continue when you are prompted to confirm the importing.
  5. Click the operation that you want to link a front-end operation to, POST/pet is selected in this tutorial; then move the cursor to the REQUEST button at the top of the flow.

  6. Click the unlinked list and then select the /cat operation as the front-end operation.

    A list of POST operations are displayed, including the one /cat in the new Cat API specification that you just imported.

    Note: If you do not choose another operation to replace the original one, it indicates that you still want to use the original back-end operation as the front-end operation. Therefore, make sure the original back-end operation is also added in your new front-end specification.

  7. Click Push updates to deploy the Microflow application.

    The application icon turns to green when the application is successfully pushed and run.

  8. Click the Endpoint link of the deployed sample Microflow application and then click View API to test the Microflow application.

  9. On the API Tester page, click the Cat resource and then post a cat using the default model schema. The front-end API operations are shown up for testing, rather than the back-end API operations.

  10. Click Try it out to send the request.

From the example you can see that your customer can use a new operation to access the service by replacing the original operation with a new front-end operation. Microflow translates the request to the front-end operation into a request in the format of the back-end API and sends it to the back-end service.

For each operations in the front-end specification, you either make sure they are explicitly linked to a back-end operation, or they exist the same way in the back-end specification; otherwise sending request to these front-end operation will fail.

Show Relationships

After linking the front-end API operation to the corresponding back-end API operation, you can use the Show relationships function to view the mapping between the API operations.

On the Microflow editing page, click Frontend API > Show relationships in the Operations section, the API operation mapping is displayed along with the configured stages of the front-end API operation: