blob: 4f1782d1f1f4fe63d00ad537762684567f2d1d9b [file] [log] [blame]
<!--
/***************************************************************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
***************************************************************************************************************************/
-->
OpenAPI Schema Part Serializing
<p>
Parameters annotated with any of the following are serialized using the registered {@link oaj.oapi.OpenApiSerializer} and
therefore support OpenAPI syntax and validation:
</p>
<ul class='javatree'>
<li class='ja'>{@link oaj.http.annotation.ResponseHeader}
<li class='ja'>{@link oaj.http.annotation.Response} (<c>Accept</c> must match <js>"text/openapi"</js>)
</ul>
<p>
For example, the following shows how a pipe-delimited list of comma-delimited numbers (e.g. <js>"1,2,3|4,5,6|7,8,9"</js>) in a response header can be converted to a 2-dimensional array of <c>Longs</c>:
</p>
<p class='bpcode w800'>
<ja>@RestMethod</ja>(method=<js>"GET"</js>, path=<js>"/testResponseHeader"</js>)
<jk>public void</jk> testResponseHeader(
<ja>@ResponseHeader</ja>(
name=<js>"My-Header"</js>,
collectionFormat=<js>"pipes"</js>,
items=<ja>@SubItems</ja>(
collectionFormat=<js>"csv"</js>,
type=<js>"integer"</js>,
format=<js>"int64"</js>,
minimum=<js>"0"</js>,
maximum=<js>"100"</js>
minLength=1,
maxLength=10
),
minLength=1,
maxLength=10
)
Value&lt;Long[][]&gt; header
) {
header.set(<jk>new</jk> Long[][]{...});
}
</p>
<p>
The following shows the same for a response body:
</p>
<p class='bpcode w800'>
<ja>@RestMethod</ja>(method=<js>"GET"</js>, path=<js>"/testResponseBody"</js>)
<jk>public void</jk> testResponseBody(
<ja>@Response</ja>(
serializers=OpenApiSerialier.<jk>class</jk>,
defaultAccept=<js>"text/openapi"</js>,
schema=<ja>@Schema</ja>(
items=<ja>@Items</ja>(
collectionFormat=<js>"pipes"</js>,
items=<ja>@SubItems</ja>(
collectionFormat=<js>"csv"</js>,
type=<js>"integer"</js>,
format=<js>"int64"</js>,
minimum=<js>"0"</js>,
maximum=<js>"100"</js>
minLength=1,
maxLength=10
)
),
minLength=1,
maxLength=10
)
)
Value&lt;Long[][]&gt; responseBody
) {...}
</p>
<p>
For more information about the valid parameter types, see {@doc juneau-marshall.OpenApiDetails.Serializers OpenAPI Serializers}
</p>