{title:'@Request', updated:'9.0.0'}

The {@link oaj.http.annotation.Request @Request} annotation can be applied to a type of a @RemoteOp-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 { | | @RemotePost | String postPet(CreatePetRequest bean); | }

| @Request | public class CreatePetRequest { | | private CreatePet pet; | | public CreatePetRequest(String name, float price) { | this. pet = new CreatePet(name, price); | } | | @Content | public CreatePet getContent() { | 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.Content}
- {@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 { | | @Content | CreatePet getContent(); | | @Query | Map<String,Object> getQueryParams(); | | @Header("E-Tag") | UUID getUUID(); | }

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