RestEasy 3.x integration
Due to Jersey2 not integrating cleanly with Guice, I'm using RestEasy 3.x for JAX-RS 2. The documentation only provides RestEasy 2.x and Jersey samples. I think that the Jersey2 module could be adapted, but I haven't looked into that yet.
If you need JAX-RS 2 support with RESTEasy, use the swagger-jersey2-jaxrs module. The module adds support for jax-rs 2 and file uploads when using Jersey 2. It should work just as well for RESTEasy, only without the file upload support. If you require it, that can be resolved differently.
Yep, that's what I'm experimenting with right now.
@ben-manes - any updates?
I only got as far as a the basics working before switching off to other tasks. What I had found was,
JerseyJaxrsConfighas to be replaced aServletContextListenersupplying aBeanConfig.- The
DefaultJaxrsScannerisn't useful because there is noApplicationbounded, so a custom scanner is needed.
That custom scanner will either pull the classes from ResteasyProviderFactory or walking the Guice injector mimic'ing what ModuleProcessor does. I haven't tried writing it yet, so that's my next task.
I integrated Guice + Jersey 1.x + Swagger 1.x a few years ago and there was a lot of quirks at the time, so I imagine there will be some unexpected issues this time around too.
It would be helpful if M2-SNAPSHOT was published as the BeanConfig in M1 does not support multiple resource packages.
Okay, here's a gist that performs the integration. Feel free to adapt as you see fit.
It was easier to scan the Guice bindings than determine how to extract the resource classes from RestEasy's registry. Most likely the DefaultJaxrsScanner will work in a non-Guice setup.
thanks @ben-manes. There is an m2-snapshot in sonatype, fyi.
I found that there's 1.5.3-M1 on Maven Central, which has the changes needed to remove the ResourceConfig class. The pom on master would indicate that 1.5.1-M1 is the latest release, which is what I was using, so I'm not sure what the version history is.
oh for shame. The snapshot wasn't pushed---I've just done it:
https://oss.sonatype.org/content/repositories/snapshots/com/wordnik/swagger-core/
Sorry about that.
The version history on Maven Central is confusing if going by dates:
http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.wordnik%22%20AND%20a%3A%22swagger-project%22
It indicates that 1.5.1-M2 was released after 1.5.3-M1.
I had expected master to be a SNAPSHOT version so when looking at the code I had taken 1.5.1-M1 instead of looking at central, which caused me to pull an old BeanConfig class. I'm not sure what the release I should point to as the latest.
master is stable, develop_2.0 is snapshot.
1.5.1-M2 is indeed newer than 1.5.3-M1.
I'm also using resteasy 3 with guice 4 but my configuration is a bit simpler https://gist.github.com/natros/370c0093fa60379c3901
I'm missing file upload support.
@natros - there's no file upload support for RESTEasy. You can easily add it on your own though by creating a SwaggerExtension. Check out https://github.com/swagger-api/swagger-core/pull/1023 for an example. Registering the SwaggerExtension is very simple as we use the standard SPI mechanism.
@ben-manes - any updates?
No, what additional information do you expect?
You asked which release to try and were provided with the information.
Sure, and I showed working code using a recent release. This works from my perspective.
Thanks. I'll keep the issue open so that we may be able to provide easier integration in the future.
@ben-manes Could you please add an example for the web.xml used? a full example would be really helpful.
I didn't use a web.xml file because I prefer running Jetty as an embedded library, so everything is configured in Guice. Here's a gist of how that's done.