Search code examples
swagger-uidropwizard

Swagger UI into dropwizard


I added folder dist from swagger-ui github and provide path to openapi.yaml in index.html

url: "/openapi/openapi.yaml"

Now I can see UI by the address http://localhost:63342/dropwizard-example/com/example/dropwizard/dist/index.html or access by the file index.html

How I can provide UI by my path? Something like: dropwizard-project-work.com:8080/dist


Solution

  • Maybe for someone will be useful. Move dist folder from swagger-ui to resources.

    In folder dist find index.html and change option url to your path of openapi specification file

    Add dropwizard-assets dependency

            <dependency>
                <groupId>io.dropwizard</groupId>
                <artifactId>dropwizard-assets</artifactId>
                <version>{dropwizard.version}</version>
            </dependency>
    

    In initialize method add Bundle

    
        @Override
        public void initialize(Bootstrap<BasicConfiguration> bootstrap) {
                bootstrap.addBundle(new AssetsBundle("/resoursePath", "/uriPath", "index.html"));
        }
    

    Now swagger UI available at localhost:{your port}/{applicationContextPath}/uriPath