Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ask DZ: Swagger API on Multiple OSGI Bundles Using Apache Karaf

DZone's Guide to

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!

· Integration Zone
Free Resource

Modernize your application architectures with microservices and APIs with best practices from this free virtual summit series. Brought to you in partnership with CA Technologies.

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.

Issue

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.

Description

Let's say I have two web services exposed as below:

  1. "http:/localhost:8181/cxf/abc?_wadl"

  2. "http:/localhost:8181/cxf/xyz?_wadl"

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:

"http:/localhost:8181/cxf/abc/api-docs"

it returns the result successfully, but on hitting Swagger on the second WSDL:

"http:/localhost:8181/cxf/xyz/api-docs"

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.

My Questions

  1. Is there any other way to run the Swagger API on Multiple OSGI bundles using Apache Karaf?

  2. Is there any way we can permanently disable the caching using this Karaf/Swagger configuration?

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

The Integration Zone is proudly sponsored by CA Technologies. Learn from expert microservices and API presentations at the Modernizing Application Architectures Virtual Summit Series.

Topics:
cxf ,java 1.7 ,swagger ,osgi ,restful web service

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}