{new} Basic Swagger Info
Let's look at the various parts of the Petstore application Swagger UI to see how they are defined.
The top part of the page shows general information about the REST interface:
The information is pulled from the {@link oajr.annotation.RestResource#swagger() @RestResource(swagger)} annotation.
In this particular case, the Swagger is pulled in from a localized Swagger JSON file located in the
org.apache.juneau.examples.rest.petstore package using the {@link oajr.vars.FileVar $F} variable.
{
Note that the {@link oajr.vars.FileVar $F} variable allows for request-locale-sensitive name matching so that you can provide localized Swagger information.
The {@link oajr.vars.FileVar $F} variable simply expands to a string to fill the {@link oajr.annotation.ResourceSwagger#value() @ResourceSwagger(value)} annotation. You could equivalently embed JSON directly into your annotation like so:
However, a more typical (and less error-prone) scenario is to define all of your Swagger as annotations:
All annotations support {@doc DefaultRestSvlVariables SVL variables}, so you could for example pull localized strings from resource bundles using {@link oajr.vars.LocalizationVar $L} variables.
A third option is to define your Swagger information in your {@link oajr.annotation.RestResource#messages @RestResource(messages)} resource bundle using predefined Swagger keywords:
Information defined in multiple locations are merged into a single set of data. When the same information is provided in multiple locations, the following order-of-precedence is used: