OpenAPI Schema Part Serializing
Parameters annotated with any of the following are serialized using the registered {@link oaj.oapi.OpenApiSerializer} and
therefore support OpenAPI syntax and validation:
- {@link oaj.http.annotation.ResponseHeader}
- {@link oaj.http.annotation.Response} (Accept must match "text/openapi")
For example, the following shows how a pipe-delimited list of comma-delimited numbers (e.g. "1,2,3|4,5,6|7,8,9") in a response header can be converted to a 2-dimensional array of Longs:
@RestMethod(method="GET", path="/testResponseHeader")
public void testResponseHeader(
@ResponseHeader(
name="My-Header",
collectionFormat="pipes",
items=@SubItems(
collectionFormat="csv",
type="integer",
format="int64",
minimum="0",
maximum="100"
minLength=1,
maxLength=10
),
minLength=1,
maxLength=10
)
Value<Long[][]> header
) {
header.set(new Long[][]{...});
}
The following shows the same for a response body:
@RestMethod(method="GET", path="/testResponseBody")
public void testResponseBody(
@Response(
serializers=OpenApiSerialier.class,
defaultAccept="text/openapi",
schema=@Schema(
items=@Items(
collectionFormat="pipes",
items=@SubItems(
collectionFormat="csv",
type="integer",
format="int64",
minimum="0",
maximum="100"
minLength=1,
maxLength=10
)
),
minLength=1,
maxLength=10
)
)
Value<Long[][]> responseBody
) {...}
For more information about the valid parameter types, see {@doc juneau-marshall.OpenApiDetails.Serializers OpenAPI Serializers}