Integrating Swagger with Jersey 2.x
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Thanks
- Labels:
-
Swagger Core
-
Swagger UI
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @rajiadi ,
I believe the best docs are still here: https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@rajiadi sounds like you're looking to change the `basePath`.
You can do so via web.xml, see: https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5#using-swa...
Replace
<param-value>http://localhost:8080/api</param-value>
With the value you need, perhaps: `http://localhost/rest`?
Or you can change it via beanConfig, see: https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5#using-swa...
beanConfig.setBasePath("/rest");
