You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cyberluke <lu...@gmail.com> on 2017/01/19 14:36:20 UTC

Swagger + SwaggerUI + CXFRS + Blueprint example

Hi, I tried several examples and none is working. There are examples that are
using Jetty, CXF, Servlet. But they are either using Java DSL, Spring XML.

For CXFRS + Blueprint I found this example:
https://github.com/apache/camel/tree/master/examples/camel-example-servlet-rest-blueprint/src/main/java/org/apache
...but it does not use Swagger.

CXFRS itself is working, but not with Swagger. Also there is some new
package camel-swagger-java that looks like it does not support XML DSL at
all.

I'm using Camel 2.17 with JBoss Studio (Fuse + Karaf). I'm testing the camel
context in local environment (Run -> Camel context without tests).

This is how I have defined the CXF with Rest server:
    <cxf:rsServer address="http://localhost:8080/rest" id="customerService">
        <cxf:serviceBeans>
            <ref component-id="tenantService"/>
        </cxf:serviceBeans>
        <cxf:providers>
            <ref component-id="jsonProvider"/>
        </cxf:providers>
    </cxf:rsServer>

Is there some way to get Swagger + SwaggerUI in Blueprint with CXFRS for
Camel 2.17 without deprecated components?

Thank you!
Lukas



--
View this message in context: http://camel.465427.n5.nabble.com/Swagger-SwaggerUI-CXFRS-Blueprint-example-tp5792817.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Swagger + SwaggerUI + CXFRS + Blueprint example

Posted by Claus Ibsen <cl...@gmail.com>.
Ask Red Hat Customer Portal about support for the JBoss Fuse product.

They provide developer support as well for their product and can tell
you how to use swagger with it.

On Thu, Jan 19, 2017 at 4:24 PM, cyberluke <lu...@gmail.com> wrote:
> The first link for camel-swagger-java is using jetty, not cxf.
>
> Plus there is a problem with restConfiguration apiProperty in Blueprint:
> Description     Resource        Path    Location        Type
> cvc-complex-type.2.4.a: Invalid content was found starting with element
> 'apiProperty'. One of
> '{"http://camel.apache.org/schema/blueprint":dataFormatProperty,
> "http://camel.apache.org/schema/blueprint":corsHeaders}' is expected.
>
> Description     Resource        Path    Location        Type
> cvc-complex-type.3.2.2: Attribute 'apiContextPath' is not allowed to appear
> in element 'restConfiguration'.
>
> Am I missing some XSD? You don't have it in your example as well.
>
>
> Anyway your CXF with Swagger2Feature example will compile, but no
> Swagger.json is produced:
>     <bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"
> id="jsonProvider"/>
>
>     <bean id="swagger2Feature"
> class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
>
>         <property name="basePath" value="/cxf/swaggerSample"/>
>     </bean>
>
>
>
>     <cxf:rsServer address="http://localhost:8080/rest" id="customerService">
>         <cxf:serviceBeans>
>             <ref component-id="tenantService"/>
>         </cxf:serviceBeans>
>         <cxf:providers>
>             <ref component-id="jsonProvider"/>
>         </cxf:providers>
>         <cxf:features>
>             <ref component-id="swagger2Feature" />
>         </cxf:features>
>     </cxf:rsServer>
>
> All of these returns 404:
> http://localhost:8080/rest/cxf/swaggerSample/
> http://localhost:8080/rest/cxf/swaggerSample/swagger.json
> http://localhost:8080/cxf/swaggerSample/swagger.json
>
> The REST service itself is working though. I'm using Apache CXF 3.1.5
> (Redhat bundle), not 3.1.7.
>
> Does this feature require Swagger Java annotations for a service? Currently
> I use annotations from package com.wordnik.swagger from some of the Camel
> examples. There is also a possibility to use io.swagger.annotations.Api,
> which is newer I guess, but it requires another pom dependency.
>
> EDIT: Now I tried io.swagger annotations and I still get the same 404
> pom.xml:
> <dependency>
>     <groupId>io.swagger</groupId>
>     <artifactId>swagger-annotations</artifactId>
>     <version>1.5.12</version>
> </dependency>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Swagger-SwaggerUI-CXFRS-Blueprint-example-tp5792817p5792820.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Swagger + SwaggerUI + CXFRS + Blueprint example

Posted by cyberluke <lu...@gmail.com>.
The first link for camel-swagger-java is using jetty, not cxf.

Plus there is a problem with restConfiguration apiProperty in Blueprint:
Description	Resource	Path	Location	Type
cvc-complex-type.2.4.a: Invalid content was found starting with element
'apiProperty'. One of
'{"http://camel.apache.org/schema/blueprint":dataFormatProperty,
"http://camel.apache.org/schema/blueprint":corsHeaders}' is expected.

Description	Resource	Path	Location	Type
cvc-complex-type.3.2.2: Attribute 'apiContextPath' is not allowed to appear
in element 'restConfiguration'.	

Am I missing some XSD? You don't have it in your example as well.


Anyway your CXF with Swagger2Feature example will compile, but no
Swagger.json is produced:
    <bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"
id="jsonProvider"/>
       
    <bean id="swagger2Feature"
class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
        
        <property name="basePath" value="/cxf/swaggerSample"/>
    </bean>
    

        
    <cxf:rsServer address="http://localhost:8080/rest" id="customerService">
        <cxf:serviceBeans>
            <ref component-id="tenantService"/>
        </cxf:serviceBeans>
        <cxf:providers>
            <ref component-id="jsonProvider"/>
        </cxf:providers>
        <cxf:features>
            <ref component-id="swagger2Feature" />
        </cxf:features>
    </cxf:rsServer> 

All of these returns 404:
http://localhost:8080/rest/cxf/swaggerSample/
http://localhost:8080/rest/cxf/swaggerSample/swagger.json
http://localhost:8080/cxf/swaggerSample/swagger.json

The REST service itself is working though. I'm using Apache CXF 3.1.5
(Redhat bundle), not 3.1.7.

Does this feature require Swagger Java annotations for a service? Currently
I use annotations from package com.wordnik.swagger from some of the Camel
examples. There is also a possibility to use io.swagger.annotations.Api,
which is newer I guess, but it requires another pom dependency.

EDIT: Now I tried io.swagger annotations and I still get the same 404
pom.xml:
<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-annotations</artifactId>
    <version>1.5.12</version>
</dependency>



--
View this message in context: http://camel.465427.n5.nabble.com/Swagger-SwaggerUI-CXFRS-Blueprint-example-tp5792817p5792820.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Swagger + SwaggerUI + CXFRS + Blueprint example

Posted by Claus Ibsen <cl...@gmail.com>.
camel-swagger-java works fine with XML DSL. See the examples
https://github.com/apache/camel/tree/master/examples

there is some that uses XML DSL

Apache CXF has its own swagger support
http://cxf.apache.org/docs/swagger2feature.html

On Thu, Jan 19, 2017 at 3:36 PM, cyberluke <lu...@gmail.com> wrote:
> Hi, I tried several examples and none is working. There are examples that are
> using Jetty, CXF, Servlet. But they are either using Java DSL, Spring XML.
>
> For CXFRS + Blueprint I found this example:
> https://github.com/apache/camel/tree/master/examples/camel-example-servlet-rest-blueprint/src/main/java/org/apache
> ...but it does not use Swagger.
>
> CXFRS itself is working, but not with Swagger. Also there is some new
> package camel-swagger-java that looks like it does not support XML DSL at
> all.
>
> I'm using Camel 2.17 with JBoss Studio (Fuse + Karaf). I'm testing the camel
> context in local environment (Run -> Camel context without tests).
>
> This is how I have defined the CXF with Rest server:
>     <cxf:rsServer address="http://localhost:8080/rest" id="customerService">
>         <cxf:serviceBeans>
>             <ref component-id="tenantService"/>
>         </cxf:serviceBeans>
>         <cxf:providers>
>             <ref component-id="jsonProvider"/>
>         </cxf:providers>
>     </cxf:rsServer>
>
> Is there some way to get Swagger + SwaggerUI in Blueprint with CXFRS for
> Camel 2.17 without deprecated components?
>
> Thank you!
> Lukas
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Swagger-SwaggerUI-CXFRS-Blueprint-example-tp5792817.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Swagger + SwaggerUI + CXFRS + Blueprint example

Posted by cyberluke <lu...@gmail.com>.
BTW: I was looking also at Camel in Action examples and searched Google &
this forum.



--
View this message in context: http://camel.465427.n5.nabble.com/Swagger-SwaggerUI-CXFRS-Blueprint-example-tp5792817p5792818.html
Sent from the Camel - Users mailing list archive at Nabble.com.