Home

Awesome

dropwizard-swagger

Build Status Coverage Status Maven Central GitHub license Become a Patron

A Dropwizard bundle that serves Swagger UI static content and loads Swagger endpoints. Swagger UI static content is taken from https://github.com/swagger-api/swagger-ui

Current version has been tested with Dropwizard 2.0.0 and Swagger 1.6.0 which supports Swagger 2 spec!

Note: if you come from previous versions there have been some changes in the way the bundle is configured, see details below.

License

http://www.apache.org/licenses/LICENSE-2.0

Version matrix

dropwizard-swaggerDropwizardSwagger APISwagger UI
< 0.50.7.x1.3.2?
0.5.x0.7.x1.3.12v2.1.4-M1
0.6.x0.8.01.3.12v2.1.4-M1
0.7.x0.8.x1.5.1-M2v2.1.4-M1
0.7.20.8.41.5.3v2.1.2
0.9.x0.9.x1.5.9v2.1.5
1.0.x1.0.x1.5.12v2.2.10
1.1.x1.1.x1.5.16v2.2.10
1.2.x1.2.x1.5.18v3.9.2
1.3.x1.3.x1.5.22v3.23.0
2.0.x2.0.x1.6.0v3.24.3

How to use it

<dependency>
    <groupId>com.smoketurner</groupId>
    <artifactId>dropwizard-swagger</artifactId>
    <version>2.0.0-1</version>
</dependency>
public class YourConfiguration extends Configuration {

    @JsonProperty("swagger")
    public SwaggerBundleConfiguration swaggerBundleConfiguration;
prop1: value1
prop2: value2

# the only required property is resourcePackage, for more config options see below
swagger:
  resourcePackage: <a comma separated string of the packages that contain your @Api annotated resources>
@Override
public void initialize(Bootstrap<YourConfiguration> bootstrap) {
    bootstrap.addBundle(new SwaggerBundle<YourConfiguration>() {
        @Override
        protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(YourConfiguration configuration) {
            return configuration.swaggerBundleConfiguration;
        }
    });
}

Additional Swagger configuration

To see all the properties that can be used to customize Swagger see SwaggerBundleConfiguration.java

A note on Swagger 2

Host and port do not seem to be needed for Swagger 2 to work properly as it uses relative URLs. At the moment I haven't run through all the scenarios so some adjustments might be needed, please open a bug if you encounter any problems.

Contributors