Ask a Question

Integrating Swagger with Jersey 2.x

New Contributor

Integrating Swagger with Jersey 2.x

Hi, I need some help with integrating swagger in Jersey 2.x JAX-RS. Specifically I want to know if we can configure the swagger endpoint to be something other than rest/swagger.json. For instance, could it be, api/myprojectfolder/myclass/swagger.json? 
Also, it shows errors like, unable to render swagger definitions, use swagger version 2.0 or higher etc. If anyone faced these issues, could you please share some fixes/resources.


Hi @rajiadi ,


I believe the best docs are still here:


I'm not sure if you can configure the `/swagger.json` path, but you can change the path of where your API will be exposed (and swagger.json would be at the root of that path). 


And as for the warnings.. swagger 2.0 is the oldest supported version of the specification in SwaggerUI. The is also OpenAPI 3.0 and (soon support for the latest) OpenAPI 3.1. 

Swagger Core's does support both Swagger 2.0 and OpenAPI 3.0, so you should be able to use that in your Jersey 2.x

Hi @ponelat, thanks for the response. But in this document, it asks us to configure the swagger url with /rest/ . Is there any way I can use something else instead of rest in the path? say /api/? It doesn't work if there is no /rest/ in the path

@rajiadi sounds like you're looking to change the `basePath`.


You can do so via web.xml, see:



With the value you need, perhaps: `http://localhost/rest`? 


Or you can change it via beanConfig, see:




Showing results for 
Search instead for 
Did you mean: