Swagger with (Apache Camel) CXFRS

811 views
Skip to first unread message

lekkie omotayo

unread,
Apr 23, 2013, 6:06:48 AM4/23/13
to swagger-sw...@googlegroups.com
Hi all,

I am trying to integrate Swagger with Camel-cxfrs

I saw this which I implemented but it didnt work. Camel-cxfrs does not use web.xml to expose REST service as such it doesnt load web.xml even though I added the file as described in the sample in the URL above.

I will appreciate any help.

Regards.



tony tam

unread,
Apr 23, 2013, 1:36:05 PM4/23/13
to swagger-sw...@googlegroups.com
The cxf example you linked to has a special injection of the @application context, which makes the swagger integration work.  You don't need a web.xml, but you do need something to bootstrap the system.

lekkie omotayo

unread,
Apr 23, 2013, 5:24:11 PM4/23/13
to swagger-sw...@googlegroups.com
I looked through the files and didn't see any @application injected at any point in the java classes. Would you be magnanimous enough to point out which Java class was annotated?

When you say bootstrap, you mean I need something to initialize and expose the REST service? If that is the case, the Camel CXFRS already does that by itself? If you mean something else, I will appreciate if you can further explain.

Regards.

tony tam

unread,
Apr 25, 2013, 9:28:24 AM4/25/13
to swagger-sw...@googlegroups.com
Hi, see here:


<property name="application" ref="basicApplication" />

Will add the application into the context so swagger can read the referenced classes through this reader:


If you look in how the resource listing is generated, it's just like any other JAX-RS resource.  So you simply need to tell the camel framework that it's available, and should be processed & exposed:


and

lekkie omotayo

unread,
May 15, 2013, 10:14:45 AM5/15/13
to swagger-sw...@googlegroups.com
Hi Tony,

I found a way to bootstrap the application and yet no lock:

<cxf:rsServer id="restv1Service"
address="${services.rest.url.prefix}/api/v1/service"
staticSubresourceResolution="true" >
<cxf:serviceBeans>
<ref bean="restRequestResourceBean" />
<ref bean="swaggerResourceJSON" />
<ref bean="swaggerResourceXML" />
</cxf:serviceBeans>
<cxf:extensionMappings>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</cxf:extensionMappings>
<cxf:providers>
<ref bean="jsonProvider" />
<ref bean="jaxbProvider" />
<ref bean="securityContext" />
</cxf:providers>
<cxf:properties> 
<entry key="application" value-ref="basicApplication"/> 
</cxf:properties>
<cxf:outInterceptors>
<ref bean="loggingOutInterceptor"/>
</cxf:outInterceptors>
<cxf:inInterceptors>
<ref bean="loggingInInterceptor"/>
</cxf:inInterceptors>
</cxf:rsServer>


I am wondering, the swagger documentation mentioned the swagger.api.basepath, swagger.version, and api.version are important. If you therefore claim that the web.xml isnt important or useful, how will Swager be able to get these values?

I am still not able to expose my REST API with swagger. I will appreciate whatever help you can give.
Reply all
Reply to author
Forward
0 new messages