Quick Tip: OpenAPI UI Index Routing

When building a REST API, it always easy to have the OpenAPI UI to be readily accessible at the index URL. Here’s how I do it.

@Path("")
public class IndexResource {

    private static final URI uri = URI.create("/swagger-ui");

    @GET
    @Operation(hidden = true)
    public Response get() {
       return Response.temporaryRedirect(uri).build();
    }

}

Leave a Reply

Your email address will not be published. Required fields are marked *