Dropwizard + swagger example

5,238 views
Skip to first unread message

tony tam

unread,
Nov 30, 2012, 10:04:44 AM11/30/12
to dropwiz...@googlegroups.com
Thanks to @andreisavu, there is now a sample of native swagger integration with dropwizard here:


questions or feedback welcome!

ryleyg

unread,
Dec 3, 2012, 6:31:37 PM12/3/12
to dropwiz...@googlegroups.com
I'm curious what opinions are out there on swagger annotations vs javadoc introspection.

i really like this:

think it's clean and forces people to write javadoc (which they should be doing anyway), but i can see the value in a regimented structure.

?
ryley

Ryan Kennedy

unread,
Dec 3, 2012, 6:45:39 PM12/3/12
to dropwiz...@googlegroups.com
Having written swagger-jaxrs-doclet, I'm of the opinion that nobody should use swagger's java/scala integration bits (extending their classes, using their annotations, etc). If you use JAX-RS then you've already fully annotated everything. You don't even have to write any JavaDocs to use the doclet, but if you do those comments are incorporated.

The extra bits of swagger classes in your inheritance chain are gross.

-- 
Ryan Kennedy

tony tam

unread,
Dec 3, 2012, 7:24:59 PM12/3/12
to dropwiz...@googlegroups.com
Extending the wordnik classes is no longer needed, but the annotations still are.  So if you don't want to modify your source, the doclet is cool (thanks for contributing that project, Ryan).  Otherwise, try out the annotation-based approach, they may just fit your fancy.

Tony

Jonathan Brownell

unread,
Apr 7, 2013, 7:39:31 PM4/7/13
to dropwiz...@googlegroups.com
I'm interested in experimenting with swagger-jaxrs-doclet vs. classic Swagger annotations in my Dropwizard Java service. But, I'm having a hard time finding any examples of Javadoc extensions supported by swagger-jaxrs-doclet. Is there any guide or example available?

As an example, I've run across an example JAX-RS doclet here:

But these seem do not seem to be supported byswagger-jaxrs-doclet, although I do need the ability to specify things like its @returnWrapped.

Any guidance would be appreciated!

-JB

Ryan Kennedy

unread,
Apr 8, 2013, 2:15:51 AM4/8/13
to dropwiz...@googlegroups.com
I think you talking about my swagger-jaxrs-doclet. If so, that doesn't use any JavaDoc extensions. Just JAX-RS annotations and regular-old JavaDoc comments.

Ryan


--
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/groups/opt_out.
 
 

Michael McCarthy

unread,
May 21, 2013, 1:20:40 PM5/21/13
to dropwiz...@googlegroups.com
Hi Ryan,

Is there a non-snapshot version of your project around?

Thanks,
Michael

Ryan Kennedy

unread,
May 21, 2013, 1:56:07 PM5/21/13
to dropwiz...@googlegroups.com, dropwiz...@googlegroups.com
Not yet. I could peel one off tonight and get it into maven central if that would be helpful. 

Ryan

Michael McCarthy

unread,
May 22, 2013, 1:33:50 AM5/22/13
to dropwiz...@googlegroups.com
That would be great. I can code against the snapshot version but we'd need a tag should we decide to use it. I can get back to you when we've made the decision rather than waste your time now, unless you were planning one anyway.

Jeremy McJunkin

unread,
Jun 10, 2013, 12:52:18 PM6/10/13
to dropwiz...@googlegroups.com
Ryan,

Thanks for this effort.  I'm new to both Dropwizard and java webservices in general.  I've found https://github.com/ryankennedy/swagger-jaxrs-doclet and added the plugin to my pom file and re-packaged, however, I'm not sure where to go from here?  Does this produce a service that I can use with: https://github.com/wordnik/swagger-ui#readme ?

Matthew Flower

unread,
Jun 11, 2013, 8:46:38 AM6/11/13
to dropwiz...@googlegroups.com
I had the same problem sometime back.  I ended up updating the dropwizard-swagger project just enough to make it work for me.  My main complaints were:

1. It didn't actually work with dropwizard 0.6.2
2. Swagger-ui didn't really work unless you matched the settings the dropwizard-swagger project wanted.

If you'd like to try it, it's up at https://github.com/MattFlower/dropwizard-swagger.  If you find it useful, it might be worth putting some more time into it.

-m

Jeremy McJunkin

unread,
Jun 11, 2013, 3:55:02 PM6/11/13
to dropwiz...@googlegroups.com
Thanks.  Is the readme valid?  I'm guessing that's for the original.  Is the work you've done in a maven repo?

Jeremy McJunkin

unread,
Jun 11, 2013, 4:03:45 PM6/11/13
to dropwiz...@googlegroups.com
Nevermind, I see that it is, however, I think what's got me confused is that I used to add the SwaggerBundle in my existing service class.  This seems like I should have a separate service running for the swagger ui.  Ill give that a try.

Jeremy McJunkin

unread,
Jun 11, 2013, 4:25:50 PM6/11/13
to dropwiz...@googlegroups.com
Ok, I see I just need to have my existing Configuration implement SwaggerUIConfigContainer, which I have done and returned my SwaggerUIConfig. However, when I start up my service, I just get an empty response from /api-docs.json

Jeremy McJunkin

unread,
Jun 11, 2013, 5:25:46 PM6/11/13
to dropwiz...@googlegroups.com
Figured it out, we had removed auto-detection of getters because that's not the implementation we wanted in our response.  Once I enabled that, it all worked.

Matthew Flower

unread,
Jun 14, 2013, 10:26:51 AM6/14/13
to dropwiz...@googlegroups.com
Happy that you were able to get it to work.  I've added a bit to the Readme about implementing the SwaggerUIConfigContainer.

-m

Ryan Kennedy

unread,
Jun 17, 2013, 12:48:52 PM6/17/13
to dropwiz...@googlegroups.com
I made some changes a couple weeks back to swagger-jaxrs-doclet so you won't need a dropwizard bundle anymore (it became tedious to try supporting multiple versions of dropwizard, particularly when crossing the boundary where some of the Bundle-type interfaces were changing). In the new world, the doclet step generates static content (HTML and JSON) and deposits it into a location that ensures the HTML and the JSON ends up as a resource in your JAR file. At that point, you just need to wire up the dropwizard AssetsBundle to serve that content up. The sample application does this today:


Ryan


Christophe Furmaniak

unread,
Jan 8, 2014, 3:11:22 PM1/8/14
to dropwiz...@googlegroups.com
I don't know if the following is related to the work of some of you, but there is now a sample usage of Swagger inside a Dropwizard project on the main swagger project pages, see https://github.com/wordnik/swagger-core/wiki/JavaDropwizard-Quickstart

Christophe Furmaniak

unread,
Jan 8, 2014, 3:12:25 PM1/8/14
to dropwiz...@googlegroups.com
Ok, that was the first post message, I can go back to bed

Gautam Priya

unread,
Oct 5, 2015, 10:46:25 AM10/5/15
to dropwizard-user
Curious - does this wiki page still exist at this place or has it moved elsewhere - https://github.com/wordnik/swagger-core/wiki/JavaDropwizard-Quickstart 

tony tam

unread,
Oct 5, 2015, 1:44:04 PM10/5/15
to dropwizard-user
Hi, please take a look at the swagger-samples directory for dropwizard + swagger integration:

jpl...@gmail.com

unread,
Oct 15, 2015, 7:52:09 AM10/15/15
to dropwizard-user
I've also forked a popular dropwizard-swagger module to https://github.com/smoketurner/dropwizard-swagger as the previous version wasn't being maintained.

-Justin
Reply all
Reply to author
Forward
0 new messages