@Request

The {@link oaj.http.annotation.Request @Request} annotation can be applied to a type of a @RemoteMethod-annotated method to identify it as a bean for setting HTTP parts through a bean-like interface.

Example:

@Remote(path="/petstore") public interface PetStore { @RemoteMethod String postPet(CreatePetRequest bean); }

@Request public class CreatePetRequest { private CreatePet pet; public CreatePetRequest(String name, float price) { this.pet = new CreatePet(name, price); } @Body public CreatePet getBody() { return this.pet; } @Query public Map<String,Object> getQueryParams() { return new ObjectMap().append("debug", true); } @Header("E-Tag") public static UUID getUUID() { return UUID.generatedUUID(); } }

PetStore store = restClient.getRemote(PetStore.class, "http://localhost:10000"); CreatePetRequest requestBean = new CreatePetRequest("Fluffy", 9.99); String response = store.postPet(requestBean);

The @Request annotation can be applied to either the class or argument.

The annotated methods must be no-arg and public. They can be named anything.

Any of the following annotations can be used on the methods:

The behavior and functionality of all of the annotations are the same as if they were used on method arguments directly. This means full support for OpenAPI serialization and validation.

Annotations on methods are inherited from parent classes and interfaces. For example, the request bean above could have defined annotations in an interface to keep them clear from the implementation:

@Request public interface CreatePetRequest { @Body CreatePet getBody(); @Query Map<String,Object> getQueryParams(); @Header("E-Tag") UUID getUUID(); }

public class CreatePetRequestImpl implements CreatePetRequest { public CreatePetRequestImpl(String name, float price) {...} @Override public CreatePet getBody() { return this.pet; } @Override public Map<String,Object> getQueryParams() { return new ObjectMap().append("debug", true); } @Override public UUID getUUID() { return UUID.generateUUID(); } }