Skip to content

A Dropwizard bundle that serves Swagger UI static content and loads Swagger endpoints. OpenApi 3.0

License

Notifications You must be signed in to change notification settings

oss92/dropwizard-swagger-v3

 
 

Repository files navigation

dropwizard-swagger-v3

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 1.3.9 and Swagger 2.0.7 which supports OpenApi 3.0 specifications

Requirements

  • Dropwizard 1.3.x
  • Swagger API 2.0.7
  • Swagger UI 3.19.2

Usage

  • Add the Maven dependency (available in Maven Central)
<dependency>
    <groupId>com.ossterdam</groupId>
    <artifactId>dropwizard-swagger-v3</artifactId>
    <version>1.0.0</version>
</dependency>
  • Add the following to your Configuration class:
public class YourConfiguration extends Configuration {

    @JsonProperty("swagger")
    public SwaggerBundleConfiguration swaggerBundleConfiguration;
  • Add the following your configuration yaml (this is the minimal configuration you need):
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 @OpenAPIDefinition annotated resources>
  • In your Application class:
@Override
public void initialize(Bootstrap<YourConfiguration> bootstrap) {
    bootstrap.addBundle(new SwaggerBundle<YourConfiguration>() {
        @Override
        protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(YourConfiguration configuration) {
            return configuration.swaggerBundleConfiguration;
        }
    });
}
  • As usual, add Swagger annotations to your resource classes and methods

  • Open a browser and hit http://localhost:<your_port>/swagger

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

About

A Dropwizard bundle that serves Swagger UI static content and loads Swagger endpoints. OpenApi 3.0

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 89.0%
  • FreeMarker 6.9%
  • HTML 3.5%
  • Shell 0.6%