WebSphere Application Server & Liberty

 View Only

Going beyond OpenAPI: MicroProfile meets API Connect - Part 2 - How

By Emily Jiang posted Fri March 03, 2023 05:55 PM

  

Authors: Chris Phillips (Global Lead Architect, IBM Integration), Emily Jiang (Cloud Native Architect, IBM App Runtime)

Hope you have read the Part 1 and curious about the ‘HOW’ part! If not, we recommend you to read the Part 1 so that you are familiar with the technologies  we are using in this part2. This part is on the ‘How’ bit. Let’s jump in.

Step 1: Create and run your application

You might have your application with MicroProfile OpenAPI enabled. If not, you can follow this Open Liberty guide to create an application or learn about how to enable MicroProfile OpenAPI if you have an application already.

You need to keep your application running for the following steps. Again, refer to this guide to learn about how to run your application.

Step 2: Obtain the Open API URL containing the documentation

MicroProfile Open API automatically exposes an end point containing Open API documentation under /openapi. Below is the diagram from MicroProfile Open API specification explaining how it works. The Open API URL is under http://<host-name>:<port-name>/openapi. Your OpenAPI document url would be http://<host-name>:9080/openapi by default. The document contains all of your application end points with some descriptions.

Importing the extracted API into API Connect (CP)

This section will explain how to take the OpenAPI URL from Open Liberty and manually import it into API Connect. This can be done via CICD but this will not be covered in this article.

  1. Take the URL from the previous section

  2. Log into your API Manager, and go to drafts.

  3. Create a new API.

  1. Click on Existing API, please make sure you have selected the correct OpenAPI Version.

  1. Put the URL from the previous section and any credentials that are required in the form.

  1. If you wish to activate straight away click the tick box, i would suggest you do not as we need to finish configuring it with the downstream address.

  1. Go through the form until you get to the API Designer

  1. If the OpenAPI specification imports a server section, you may need to remove it from the designer by performing the following 2 steps.

    1. Click on General->Servers

b. Click on the bin icon to the right of the entries in Servers.

  1. Click on Gateway → Properties → Target URL

  1. Set the Target URL to be the the base path of the downstream system and append the path variable similar to below

  • `https://downstreamsystemhostname/$(request.path)`

  • The ‘request.path’ variable allow for the path to be passed in from the request to the downstream call.

  1. Click on Save and offline in the top right to publish it. If it is already online then it will be automatically republished.

  1. The API is now deployed to your gateway and developer portal

Good Considerations

MicroProfile OpenAPI:

  • Well-documented functions: Always use MicroProfile OpenAPI annotations to document your end points.

API Connect Gateway:

Conclusion

In this article we showed how to apply the theory of Part 1. This part 2 shows how to import an OpenAPI Specification easily and quickly from the MicroProfile OpenAPI supported in Open Liberty into your API Connect. Now, you can easily secure and track the downstream service usage in a consistent and common pattern. 

0 comments
33 views

Permalink