{new} Response Examples
The model select box in the responses can be expanded to show examples:
Examples are provided for any supported Accept type based on the serializers defined on your
servlet/method.
Examples are pulled from the examples attribute in the response object of the generated Swagger JSON:
There are several options for defining examples for response bodies:
@ResourceSwagger (value)/@MethodSwagger (value)).
The {@link oaj.http.annotation.Response#example @Response(example)} annotation can be used on either your
This is a Simple JSON representation of the body that is converted to a POJO and then serialized to all the registered serializers on the REST method to produce examples for all
supported language types.
These values are then used to automatically populate the examples field.
Direct per-media-type examples can also be defined using the {@link oaj.http.annotation.Response#examples @Response(examples)} annotation:
Juneau also supports auto-generation of JSON-Schema directly from POJO classes.
By default, the generated swagger uses to the {@link oaj.jsonschema.JsonSchemaGenerator#JSONSCHEMA_addExamplesTo JSONSCHEMA_addExamplesTo}
setting to automatically add examples to beans, collections, arrays, and maps:
In particular, examples can be defined via static methods, fields, and annotations on the classes themselves.
Examples can also be specified via generic properties as well using the {@link oaj.BeanContext#BEAN_examples} property at either the class or method level.
Response headers are also rendered in the Swagger UI:
These can be auto-generated from {@link oaj.http.annotation.ResponseHeader @ResponseHeader} annotations defined on either
method parameters or type classes.
The example above shows one of each: