{new} Parameter Examples
The model select box in the parameters can be expanded to show examples:
The examples for query/form-data/path/header parameters can be defined using the example attribute on your annotated parameters as shown here:
This value gets converted to an x-examples attribute in your parameter information:
{
Examples for request bodies includes all supported Content-Type values:
These are based on the parsers registered on your servlet or method.
Selecting any of the content types shows you a representative example for the POJO:
There are several options for defining examples for request bodies:
@ResourceSwagger (value)/@MethodSwagger (value)).
When using {@link oaj.http.annotation.Body#example() @Body(example)}, you specify a Simple JSON representation of your POJO. The Swagger generator will then convert that JSON into a POJO using the registered serializers on the REST method to produce examples for all supported language types.
The {@link oaj.http.annotation.Body#examples() @Body(examples)} annotation allows you to specify raw output values per media type. This field allows you to override the behavior and show examples for only specified media types or different examples for different media types.
The Swagger generator uses these to create an x-examples entry in your generated Swagger:
Another option is to define these directly in your resource Swagger JSON file, or via {@link oajr.annotation.RestResource#swagger() @RestResource(swagger)}/{@link oajr.annotation.RestMethod#swagger() @RestMethod(swagger)}.
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:
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.