How to add Swagger UI to existing GXT or GWT project and use current GWT-RPC REST requests?

326 Views Asked by At

We have working GXT (GWT) project. We want to add new JavaScript frontend to this application.

  1. Can we use current GWT-RPC REST requests from JavaScript?
  2. If yes: How to add Swagger UI for existing GWT-RPC REST requests?
1

There are 1 best solutions below

0
Ignacio Baca On

GWT-RPC is NOT a REST service, so it cannot be exposed using OpenAPI Specification.

If your server is a Java server you can use some JAX-RS implementation like jersey to expose REST services. And access to those services on the client side using RestyGWT or AutoREST for example.

At that point, you will be using a REST API. Then you need to create, expose and consume the OpenAPI Specification of your services. Here there is a guide to expose the OpenAPI Specification from your JAX-RS interfaces using jersey.

https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5

Swagger UI is a standalone app. So you can either access it in a new window or integrate it in your GWT app using an iframe. Loading the Swagger UI using JS into your GWT app is possible, but unnecessary complicated IMO. The jersey-swagger guide includes the Swagger UI exposed as a static resource in your war.