@Body

The {@link oaj.http.annotation.Body @Body} annotation can be applied to arguments of @RemoteMethod-annotated methods to denote that they are the HTTP body of the request.

- {@link oaj.http.annotation.Body}
  - {@link oaj.http.annotation.Body#required() required} - Input validation. Body must be present.
  - {@link oaj.http.annotation.Body#schema() schema} - Swagger schema.

##### Examples:

// Used on parameter @Remote(path="/petstore") public interface PetStore { @RemoteMethod(path="/pets") String addPet(@Body Pet pet); }

// Used on class @Remote(path="/petstore") public interface PetStore { @RemoteMethod(path="/pets") String addPet(Pet pet); } @Body public class Pet {...}

The argument can be any of the following types:

- Any serializable POJO - Converted to output using the {@link oaj.serializer.Serializer} registered with the RestClient.
  Content-Type is set to that of the Serializer.
- {@link java.io.Reader} - Raw contents of {@code Reader} will be serialized to remote resource.
  Content-Type is set to "text/plain".
- {@link java.io.InputStream} - Raw contents of {@code InputStream} will be serialized to remote resource.
  Content-Type is set to "application/octet-stream".
- NameValuePairs - Converted to a URL-encoded FORM post.
  Content-Type is set to "aplication/x-www-form-urlencoded".
- HttpEntity - Bypass Juneau serialization and pass HttpEntity directly to HttpClient.

OpenAPI schema based serialization can be used by using the {@link oaj.oapi.OpenApiSerializer} class.

@RemoteMethod(path="/comma-delimited-pipe-delimited-ints") String addCommaDelimitedPipeDelimitedInts( @Body( serializer=OpenApiSerializer.class, schema=@Schema( type="array", collectionFormat="pipes", items=@Items( type="array" items=@SubItems( type="int32", // Auto-validates on client side! minimum="0", maximum="64" ) ) ) ) int[][] input );

See {@doc juneau-marshall.OpenApiDetails.Serializers} for information about supported data types in OpenAPI serialization.

If your RestClient class does not have a serializer associated with it, the body will automatically be serialized to a string using the rules defined in {@doc PojosConveribleToStrings}.