Skip to content

Instantly share code, notes, and snippets.

SwapiService swapiService =
RestClientBuilder.newBuilder()
.baseUrl(new URL("https://swapi.dev/api"))
.build(SwapiService.class);
JsonObject character = swapiService.getCharacter(id);
@bgoetzmann
bgoetzmann / GreetingResource.java
Created April 13, 2023 11:54
REST resource for restclient application
package odelia.restclient;
import javax.inject.Inject;
import javax.json.JsonObject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@bgoetzmann
bgoetzmann / SwapiService.java
Created April 13, 2023 18:50
Interface to call SWAPI in restclient application
package odelia.restclient;
import javax.json.JsonObject;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;