Every day new APIs are being deployed and existing APIs are being adopted by new clients. The need for a consistent way to share the contract (the Swagger definition) between server and clients exist in all levels, such on-premise and local/public/hybrid cloud environments.
This blog is a follow-up to our WebSphere Liberty API discovery introduction and takes you on the journey of adding Swagger support to your assets, exposing them on-premise, pushing them into the cloud, and finally integrating them with a powerful API management solution.
We start by taking a closer look at our sample application which has Swagger annotations as well as a pre-generated Swagger document for the servlet portion of the web module. You’ll learn how these annotations augment existing JAX-RS annotations, and how it is all rendered into WebSphere Liberty’s native Swagger UI:
To recap from the last video, there are three patterns for exposing Swagger in Liberty:
- Using annotations (bottom-up)
- Placing a pre-generated Swagger document inside META-INF (top-down)
- Using annotations together with a pre-generated Swagger document inside META-INF/stub (hybrid)
Now that you’re familiar with deploying applications on-premise, let’s take a look at how to lift-and-shift your applications into the cloud! This is easily done by using Cloud Foundry, which underpins IBM Cloud:
Now you have assets running on-prem and in the cloud! The last step in this API journey is to integrate your APIs with an API management framework. IBM’s new API Connect framework is a great place to manage and secure your APIs. In this next video I demonstrate how you can easily integrate your WebSphere Liberty’s APIs with API Connect within minutes! Check it out:
As a developer, you can now easily test your application from end-to-end, including how it is exposed via API Connect, by using WebSphere Liberty’s Swagger UI to test the application endpoints and push them into API Connect. Administrators and/or business users can use API Connect’s toolkit to create a
product.yaml) that they can check into their source repository, and this asset can be used to trigger the
/ibm/api/docs/apiconnect endpoint (i.e. via curl) in a continuous integration framework.
For enterprises that want to decouple the Swagger processing from their live servers, we have you covered too! We released an open source, “offline” version of WebSphere Liberty’s processor that works with a WAR input and produces the corresponding JSON or YAML Swagger definition. It supports the exact same three patterns that the “online” version supports. Check it out here. Note that you can use this to enable Swagger processing of your WebSphere Application Server traditional instances as well.