(Quick Reference)

7 Swagger Integration

Version: 3.1.0

7 Swagger Integration

With the jersey1 implementation of the JAX-RS plugin, Swagger 2.0 support is built-in, although it is disabled by default.

When Swagger is enabled, the /swagger.json endpoint is exposed containing the details about the application's API services, assuming the resources are annotated with the proper Swagger annotations.

Configuration

All of the Swagger configuration options are set under the path org.grails.jaxrs.swagger. The following options are available.

Configuration PropertyRequiredDescriptionTypeDefault
enabledIf true, /swagger.json will be exposed with details regarding the API service.Booleanfalse
beanConfigClassName The fully qualified class name of a custom instance of BeanConfig used to provide information about the API service. This is useful when applications need to provide additional information, such as security requirements.String 
resourcePackageThe package that swagger should scan for JAX-RS resources. Multiple packages may be provided as a comma-separated list.String 
version The API version number.String1
title The title of the API service. If this is not set, the application name is used.StringApplication name.
description The description of the API service.String 
contact Contact information.String 
license License name.String 
licenseUrl URL to information about the license.String 
scan Whether Swagger should scan for resources.Booleantrue
baseUrl The base URL to the API service. This is useful when the application lives behind a load balancer.StringThe application's discovered base URL.

Swagger UI

When the jaxrs-swagger-ui plugin is included in an application, the Swagger UI is exposed with the path /showRestApi. The UI has been modified only in that it is hardcoded to query the application itself for the swagger.json information.