@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.

- {@link oaj.http.annotation.Request}
  - {@link oaj.http.annotation.Request#serializer() serializer} - Override the part serializer.

##### 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 AMap.of("debug", true); } @Header("E-Tag") public static UUID getUUID() { return UUID.generatedUUID(); } }

PetStore store = client.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:

- {@link oaj.http.annotation.Body}
- {@link oaj.http.annotation.Header}
- {@link oaj.http.annotation.FormData}
- {@link oaj.http.annotation.Query}
- {@link oaj.http.annotation.Path}

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 OMap.of("debug", true); } @Override public UUID getUUID() { return UUID.generateUUID(); } }