Giter Site home page Giter Site logo

darewreck54 / dropwizard-swagger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smoketurner/dropwizard-swagger

0.0 0.0 0.0 24.37 MB

a Dropwizard bundle that serves Swagger UI static content and loads Swagger endpoints.

License: Apache License 2.0

Shell 0.56% Java 89.50% FreeMarker 6.61% HTML 3.33%

dropwizard-swagger's Introduction

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 1.3.7 and Swagger 1.5.21 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-swagger Dropwizard Swagger API Swagger UI
 < 0.5        |   0.7.x    |  1.3.2    |    ?
   0.5.x      |   0.7.x    |  1.3.12   | v2.1.4-M1
   0.6.x      |   0.8.0    |  1.3.12   | v2.1.4-M1
   0.7.x      |   0.8.x    |  1.5.1-M2 | v2.1.4-M1
   0.7.2      |   0.8.4    |  1.5.3    | v2.1.2
   0.9.x      |   0.9.x    |  1.5.9    | v2.1.5
   1.0.x      |   1.0.x    |  1.5.12   | v2.2.10
   1.1.x      |   1.1.x    |  1.5.16   | v2.2.10
   1.2.x      |   1.2.x    |  1.5.18   | v3.9.2
   1.3.x      |   1.3.x    |  1.5.21   | v3.19.2

How to use it

  • Add the Maven dependency (available in Maven Central)
<dependency>
    <groupId>com.smoketurner</groupId>
    <artifactId>dropwizard-swagger</artifactId>
    <version>1.3.7-1</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 @Api 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

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

dropwizard-swagger's People

Contributors

akraxx avatar alanturner avatar chmodas avatar dchesterman avatar demesne avatar dependabot-preview[bot] avatar dependabot-support avatar drane avatar dren-dk avatar eciuca avatar federecio avatar felixgao avatar gauravic08 avatar ianrogers-lshift avatar jameslauser avatar jerrylawson avatar jplock avatar mattcarrier avatar mcarrierastonish avatar mikerippon avatar msmerc avatar pphatak avatar quirinius avatar reftel avatar sfdc-matrix-salt-bootstrap avatar tburch avatar trasa avatar wonno avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.