{title:'@Content', updated:'8.2.0', updated:'9.0.0'}

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

Examples:

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

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

The argument can be any of the following types:

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

| @RemotePost("/comma-delimited-pipe-delimited-ints") | String addCommaDelimitedPipeDelimitedInts( | @Content( | 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 | );

| // Same as above but using free-form schema. | // Format is simplified-JSON (outer {} brackets are optional). | @RemotePost("/comma-delimited-pipe-delimited-ints") | String addCommaDelimitedPipeDelimitedInts( | @Content( | serializer=OpenApiSerializer.class, | schema=@Schema( | "type:'array',collectionFormat:'pipes',items:[type:'array',items:[type:'int32',minimum:0,maximum:64]]" | ) | ) | int[][] input | );

See OpenAPI 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 POJO Categories.