Hi,

for automated API documentation I tried to get Swagger (http://developers.helloreverb.com/swagger/) to work with CXF. It is really a beautiful way to document your rest services and it would be great if we can get this work with CXF. Currently it doesn't work because of the following problem:

Their implementation for API resource listing relies on the injection of two objects via @Context annotation:

javax.servlet.ServletConfig
javax.ws.rs.core.Application

The first one works, the second one doesn't and returns null instead.

When I look at the documentation at http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Contextannotations, it seems Application is not supported for injection.

The ticket for Swagger is here: https://github.com/wordnik/swagger-core/issues/82 A sample app can be found here: https://github.com/rvullriede/swagger-core/tree/master/samples/swagger-java-sample-app-cxf

To get the sample to work you have to add the sonatype snapshot repository (https://oss.sonatype.org/content/repositories/snapshots/) to you maven configuration.

After that you can run the sample with mvn tomcat:run and access the app under context /swagger-cxf

GET http://localhost:8080/swagger-cxf/api => CXF Servlet Endpoint GET http://localhost:8080/swagger-cxf/api/v1.0?_wadl => autogenerated WADL for CXF service /v1.0 GET http://localhost:8080/swagger-cxf/api/v1.0/user.json/user1 => example request for user resource

GET http://localhost:8080/swagger-cxf/api/v1.0/api-docs.json => returns an NPE because of missing Application.

Does anybody have an idea how to get this work?

Thanks for your help,
Raphael



Reply via email to