Search code examples
cachingjerseyglassfish-3swagger

Clear swagger Cache for Jersey project


I have created Java RESTFUL web serivces using Jersey, I am using swagger for API documentation. however swagger annotation changes during development for my RESTFUL services are not visible, I have tried clearing browser cache and used other browsers as well, but new changes does not reflect on Swagger API documentation. Swagger core dependencies are located in shared libraries directory.

Wokaround In order for the changes to take effect I have to delete the following folders in Glass-fish.

  1. generated
  2. osgi-cache

and then redeploy the application (this require complete shutdown of the Glass fish server, otherwise system does not allow me to delete above folders.)

My Questions: 1 - Is there any way we can permanently disabled the caching?

2 - Is there any method to clear swagger cache on demand without restarting or deleting the folders?

<dependency>
    <groupId>com.wordnik</groupId>
    <artifactId>swagger-jaxrs_2.10</artifactId>
    <version>1.3.10</version>
</dependency>

Solution

  • Following the comments above, the solution is to use com.wordnik.swagger.jaxrs.listing.ApiListingCache.invalidateCache() during the start up of the application.

    It should be noted that for some version of swagger-core, some parts are static and as such, using it as a shared lib will override the definitions for all the applications that use it on the same application server. The better solution would be to include the swagger-core dependency in each application separately.