Difference between 'com.yammer.dropwizard' and 'io.dropwizard'

1,226 views
Skip to first unread message

Todd Decker

unread,
Jun 27, 2014, 1:32:20 PM6/27/14
to dropwiz...@googlegroups.com, Rajeshkannan Rajendran
So, I'm working through trying to bash together the dropwizard hello world application sample with swagger. I started by trying to merge in code examples from swagger's dropwizard integration kickstart sample (https://github.com/wordnik/swagger-core/wiki/JavaDropwizard-Quickstart). I'm encountering some problems that on the surface seem to be due to some changes to dropwizard.  The swagger quickstart code seems to be based on dropwizard when it was under the yammer umbrella and includes the following class imports:

import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment;


However, the current dropwizard hellow world uses with dropwizard.Service missing entirely:

import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;

import io.dropwizard.setup.Environment;


For registering a resource, the Swagger sample uses:

environment.addResource( .... );


And the dropwizard hello world uses:

environment.jersey().register(...);


I assume I can make the world right but going with the io.dropwizard imports instead of com.yammer.dropwizard and moving from the addResource method to jersey().register method.

Is this accurate?

Is there a place where I can learn what other impacts exist from the move from com.yammer.dropwizard classes to io.dropwizard?

How should I replace the environment.addProvider(...) methods in the older Swagger quickstart?

Thank you in advance for the help.

P. Todd

Todd Decker

unread,
Jun 27, 2014, 1:34:28 PM6/27/14
to dropwiz...@googlegroups.com, raj...@ligosphere.com

Justin Miller

unread,
Jun 27, 2014, 1:36:29 PM6/27/14
to dropwiz...@googlegroups.com
Hey Todd,

Here's what I use in DW 0.7.0 for Swagger init:

// swagger setup (http://swagger.wordnik.com/)
environment.jersey().register(new ApiListingResourceJSON());
environment.jersey().register(new ApiDeclarationProvider());
environment.jersey().register(new ResourceListingProvider());
ScannerFactory.setScanner(new DefaultJaxrsScanner());
ClassReaders.setReader(new DefaultJaxrsApiReader());

SwaggerConfig swaggerConfig = ConfigFactory.config();
swaggerConfig.setApiVersion(API_VERSION);
swaggerConfig.setBasePath("..");

/* Allow CORS for Swagger */
FilterRegistration.Dynamic filter =
environment.servlets().addFilter("CORS", CrossOriginFilter.class);
filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class),
true, "/*");
filter.setInitParameter("allowedOrigins", "*");
filter.setInitParameter("allowedHeaders",
"Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin");
filter.setInitParameter("allowedMethods",
"GET,PUT,POST,DELETE,OPTIONS");
filter.setInitParameter("preflightMaxAge", "5184000"); // 2 months
filter.setInitParameter("allowCredentials", "true");

The CORS section I add as I use a separate swagger-ui server.

I'm not sure when the change occurred, but you can check the change
logs to see exactly when the package names changed.

Best,
Justin
> --
> You received this message because you are subscribed to the Google Groups
> "dropwizard-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dropwizard-us...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Todd Decker

unread,
Jun 27, 2014, 2:06:18 PM6/27/14
to dropwiz...@googlegroups.com
Justin,

Thanks a bunch!  I was able to get it to work too (but probably not as clean as your work, c.f. swagger branch of https://github.com/LigoSphere/dwhello).

I love that happy feeling when something works (and love dropwizard + swagger).

Now off to enabling OAuth 2.0 and then I'll feel like I'm at a stable reference point for building out something real I can use at LigoSphere. We currently use Parse as the backend to our iOS and Android apps with no application layer and I've decided to introduce a Dropwizard based stack middle tier sitting on top of Postgres.

Thank you for your help.

P. Todd

Patrick van Dissel

unread,
Jun 27, 2014, 2:28:27 PM6/27/14
to dropwiz...@googlegroups.com

FYI, I came across the following,
- https://github.com/federecio/dropwizard-swagger
  A dropwizard bundle
- https://github.com/wordnik/swagger-core/tree/master/samples/java-dropwizard
  A sample of using swagger with dropwizard in the swagger core samples 😀

/Patrick

Reply all
Reply to author
Forward
0 new messages