1
votes

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>
1
Do you use hot swapping during development or do you deploy the whole application each time? - Ron
deploy whole application each time. - Fido XLNC
This is a bit odd. If you redeploy the whole application and restart the server, there shouldn't be any caching issues at all. - Ron
This is swagger internal caching problem. I am using "swaggerVersion": "1.2". i changed my apiVersion but it is still showing me older api version for "apis" endpoints (api/api-docs/pet) also it is not picking annotations for @ApiResponses e.t.c - Fido XLNC
That's the version of the Swagger specification, not the version of swagger-core. Which version is that, by the way? And the caching is a runtime thing, so once you shut the app down, the caching should be gone. - Ron

1 Answers

1
votes

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.