Ask DZ: Swagger API on Multiple OSGI Bundles Using Apache Karaf
This author is having an issue with a possible caching issue dealing with Swagger's api-docs. Think you may know a solution to his conundrum? Leave a comment!
Join the DZone community and get the full member experience.Join For Free
I have created Java RESTful web services using Apache Karaf, using Swagger for API documentation. All annotations are applied, and it's running successfully on a single OSGI bundle with the general Swagger configuration (Swagger core and the annotations JAR) with Apache Karaf on standalone mode.
While running Swagger on multiple OSGI bundles, it is catching the result generated while hitting "/api-docs" on the very first WSDL, and it returns the same for other WSDL's as well.
Let's say I have two web services exposed as below:
The web services are exposed on two different OSGI bundles and all the configurations are written in their respective "bluprint.xml" files. The Swagger Core and Swagger annotations dependencies are located in each project's pom.xml.
When I run Swagger API on the first WSDL:
it returns the result successfully, but on hitting Swagger on the second WSDL:
it returned the same result, which was initially produced by the first WSDL. It cached the first WSDL JSON somewhere and always returns the initial result.
Is there any other way to run the Swagger API on Multiple OSGI bundles using Apache Karaf?
Is there any way we can permanently disable the caching using this Karaf/Swagger configuration?
Is there any method to clear the Swagger cache (which got created when I made a hit to
http:/localhost:8181/cxf/abc/api-docs) when hitting Swagger for the next OSGI bundles (
http:/localhost:8181/cxf/xyz/api-docs), so it rescans the API annotations and doesn't return the cached result?
Note: I have implemented the Swagger API on OSGI bundles using: https://github.com/ddragosd/jax-rs-on-karaf
Opinions expressed by DZone contributors are their own.