camel cxfrs with swagger.

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

camel cxfrs with swagger.

atg roxx
Hi Team,

I am using camel 2.14 and I am trying to expose rest endpoint using CXFRS
and want to use swagger to expose the rest api.


I am able to expose my rest service using cxfrs as described here :
http://camel.apache.org/cxfrs.html

My application is not a web application, and I am using spring and spring
boot for my application.

So I dont have web.xml in my case.

Now for Integrating with Swagger, I looked at
http://camel.apache.org/swagger.html

but it uses web.xml for it.

Is there anyways we can do it without using web.xml.

I looked at the exmple "camel-example-servlet-rest-tomcat" (
http://camel.apache.org/examples.html) explaining swagger integration with
 Camel, but here too web application is used for example i.e web.xml for
this integration.


Could anyone suggest how can we integrate swagger without use  of web.xml


-Cheers,
atg roxx
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

Sergey Beryozkin
Hi

Freeman added org.apache.cxf.jaxrs.swagger.SwaggerFeature to the CXF
cxf-rt-rs-service-description module, you can register it as a CXFRS
feature. Perhaps it can help ?

Cheers, Sergey


On 17/10/14 10:18, atg roxx wrote:

> Hi Team,
>
> I am using camel 2.14 and I am trying to expose rest endpoint using CXFRS
> and want to use swagger to expose the rest api.
>
>
> I am able to expose my rest service using cxfrs as described here :
> http://camel.apache.org/cxfrs.html
>
> My application is not a web application, and I am using spring and spring
> boot for my application.
>
> So I dont have web.xml in my case.
>
> Now for Integrating with Swagger, I looked at
> http://camel.apache.org/swagger.html
>
> but it uses web.xml for it.
>
> Is there anyways we can do it without using web.xml.
>
> I looked at the exmple "camel-example-servlet-rest-tomcat" (
> http://camel.apache.org/examples.html) explaining swagger integration with
>   Camel, but here too web application is used for example i.e web.xml for
> this integration.
>
>
> Could anyone suggest how can we integrate swagger without use  of web.xml
>
>
> -Cheers,
> atg roxx
>


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

Matt Raible
In reply to this post by atg roxx
Here's how I did it.

Application.java (to register Camel's servlet):
----
import org.apache.camel.component.servlet.CamelHttpTransportServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.ErrorPage;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {
        private static final String CAMEL_URL_MAPPING = "/rest/*";
        private static final String CAMEL_SERVLET_NAME = "CamelServlet";

        public static void main(String[] args) {
                SpringApplication.run(Application.class, args);
        }

        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
                return application.sources(Application.class);
        }

        @Bean
        public ServletRegistrationBean servletRegistrationBean() {
                ServletRegistrationBean registration =
                                new ServletRegistrationBean(new CamelHttpTransportServlet(), CAMEL_URL_MAPPING);
                registration.setName(CAMEL_SERVLET_NAME);
                return registration;
        }

        @Bean
        public EmbeddedServletContainerCustomizer containerCustomizer() {
                return new EmbeddedServletContainerCustomizer() {
                        @Override
                        public void customize(ConfigurableEmbeddedServletContainer container) {
                                ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
                                ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
                                ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");

                                container.addErrorPages(error401Page, error404Page, error500Page);
                        }
                };
        }
}

SwaggerConfig.java:
----
@Configuration
public class SwaggerConfig implements EnvironmentAware {

    private RelaxedPropertyResolver propertyResolver;

    @Override
    public void setEnvironment(Environment environment) {
    this.propertyResolver = new RelaxedPropertyResolver(environment, "swagger.");
    }

    /**
     * Swagger Camel Configuration
     */
    @Bean
    public ServletRegistrationBean swaggerServlet() {
    ServletRegistrationBean swagger = new ServletRegistrationBean(new SpringRestSwaggerApiDeclarationServlet(), "/swagger/*");
    Map<String, String> params = new HashMap<>();
    params.put("base.path", "https://localhost:8443/rest");
    params.put("api.title", propertyResolver.getProperty("title"));
    params.put("api.description", propertyResolver.getProperty("description"));
    params.put("api.termsOfServiceUrl", propertyResolver.getProperty("termsOfServiceUrl"));
    params.put("api.license", propertyResolver.getProperty("license"));
    params.put("api.licenseUrl", propertyResolver.getProperty("licenseUrl"));
    swagger.setInitParameters(params);
    return swagger;
    }

}

application.properties:
----
# Swagger
swagger.title = My API
swagger.description = A description.
swagger.termsOfServiceUrl = http://yourcompany.com/terms.html
swagger.contact =
swagger.license = Apache 2.0
swagger.licenseUrl = http://www.apache.org/licenses/LICENSE-2.0.html

Hope this helps,

Matt

On Fri, Oct 17, 2014 at 3:18 AM, atg roxx <[hidden email]> wrote:
Hi Team,

I am using camel 2.14 and I am trying to expose rest endpoint using CXFRS
and want to use swagger to expose the rest api.


I am able to expose my rest service using cxfrs as described here :
http://camel.apache.org/cxfrs.html

My application is not a web application, and I am using spring and spring
boot for my application.

So I dont have web.xml in my case.

Now for Integrating with Swagger, I looked at
http://camel.apache.org/swagger.html

but it uses web.xml for it.

Is there anyways we can do it without using web.xml.

I looked at the exmple "camel-example-servlet-rest-tomcat" (
http://camel.apache.org/examples.html) explaining swagger integration with
 Camel, but here too web application is used for example i.e web.xml for
this integration.


Could anyone suggest how can we integrate swagger without use  of web.xml


-Cheers,
atg roxx



--
720-560-8460
http://raibledesigns.com
http://linkedin.com/in/mraible
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

atg roxx
Hi Matt/Sergey,

Thanks for replying.

Sergey,

I was not sure where and how to user your SwaggerFeature.. not sure where
it will fit.

Matt,

In your approach too, could not see the use of camel cxfrs and also there
are not camel routes to server the request.

In Swagger config, could not see any resource location to search for
resources class.

Could you if possible , kindly let me know where how to use these in your
sample program.

-Regards,
atg roxx

On Fri, Oct 17, 2014 at 3:08 PM, Matt Raible <[hidden email]> wrote:

> Here's how I did it.
>
> Application.java (to register Camel's servlet):
> ----
> import org.apache.camel.component.servlet.CamelHttpTransportServlet;
> import org.springframework.boot.SpringApplication;
> import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
> import org.springframework.boot.builder.SpringApplicationBuilder;
> import
> org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
> import
> org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
> import org.springframework.boot.context.embedded.ErrorPage;
> import org.springframework.boot.context.embedded.ServletRegistrationBean;
> import org.springframework.boot.context.web.SpringBootServletInitializer;
> import org.springframework.context.annotation.Bean;
> import org.springframework.context.annotation.ComponentScan;
> import org.springframework.context.annotation.Configuration;
> import org.springframework.http.HttpStatus;
>
> @Configuration
> @ComponentScan
> @EnableAutoConfiguration
> public class Application extends SpringBootServletInitializer {
>         private static final String CAMEL_URL_MAPPING = "/rest/*";
>         private static final String CAMEL_SERVLET_NAME = "CamelServlet";
>
>         public static void main(String[] args) {
>                 SpringApplication.run(Application.class, args);
>         }
>
>         @Override
>         protected SpringApplicationBuilder
> configure(SpringApplicationBuilder application) {
>                 return application.sources(Application.class);
>         }
>
>         @Bean
>         public ServletRegistrationBean servletRegistrationBean() {
>                 ServletRegistrationBean registration =
>                                 new ServletRegistrationBean(new
> CamelHttpTransportServlet(), CAMEL_URL_MAPPING);
>                 registration.setName(CAMEL_SERVLET_NAME);
>                 return registration;
>         }
>
>         @Bean
>         public EmbeddedServletContainerCustomizer containerCustomizer() {
>                 return new EmbeddedServletContainerCustomizer() {
>                         @Override
>                         public void
> customize(ConfigurableEmbeddedServletContainer container) {
>                                 ErrorPage error401Page = new
> ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
>                                 ErrorPage error404Page = new
> ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
>                                 ErrorPage error500Page = new
> ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
>
>                                 container.addErrorPages(error401Page,
> error404Page, error500Page);
>                         }
>                 };
>         }
> }
>
> SwaggerConfig.java:
> ----
> @Configuration
> public class SwaggerConfig implements EnvironmentAware {
>
>     private RelaxedPropertyResolver propertyResolver;
>
>     @Override
>     public void setEnvironment(Environment environment) {
>         this.propertyResolver = new RelaxedPropertyResolver(environment,
> "swagger.");
>     }
>
>     /**
>      * Swagger Camel Configuration
>      */
>     @Bean
>     public ServletRegistrationBean swaggerServlet() {
>         ServletRegistrationBean swagger = new ServletRegistrationBean(new
> SpringRestSwaggerApiDeclarationServlet(), "/swagger/*");
>         Map<String, String> params = new HashMap<>();
>         params.put("base.path", "https://localhost:8443/rest");
>         params.put("api.title", propertyResolver.getProperty("title"));
>         params.put("api.description",
> propertyResolver.getProperty("description"));
>         params.put("api.termsOfServiceUrl",
> propertyResolver.getProperty("termsOfServiceUrl"));
>         params.put("api.license", propertyResolver.getProperty("license"));
>         params.put("api.licenseUrl",
> propertyResolver.getProperty("licenseUrl"));
>         swagger.setInitParameters(params);
>         return swagger;
>     }
>
> }
>
> application.properties:
> ----
> # Swagger
> swagger.title = My API
> swagger.description = A description.
> swagger.termsOfServiceUrl = http://yourcompany.com/terms.html
> swagger.contact =
> swagger.license = Apache 2.0
> swagger.licenseUrl = http://www.apache.org/licenses/LICENSE-2.0.html
>
> Hope this helps,
>
> Matt
>
> On Fri, Oct 17, 2014 at 3:18 AM, atg roxx <[hidden email]> wrote:
> Hi Team,
>
> I am using camel 2.14 and I am trying to expose rest endpoint using CXFRS
> and want to use swagger to expose the rest api.
>
>
> I am able to expose my rest service using cxfrs as described here :
> http://camel.apache.org/cxfrs.html
>
> My application is not a web application, and I am using spring and spring
> boot for my application.
>
> So I dont have web.xml in my case.
>
> Now for Integrating with Swagger, I looked at
> http://camel.apache.org/swagger.html
>
> but it uses web.xml for it.
>
> Is there anyways we can do it without using web.xml.
>
> I looked at the exmple "camel-example-servlet-rest-tomcat" (
> http://camel.apache.org/examples.html) explaining swagger integration with
>  Camel, but here too web application is used for example i.e web.xml for
> this integration.
>
>
> Could anyone suggest how can we integrate swagger without use  of web.xml
>
>
> -Cheers,
> atg roxx
>
>
>
> --
> 720-560-8460
> http://raibledesigns.com
> http://linkedin.com/in/mraible
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

Sergey Beryozkin
This is a link Freeman kindly shared with me earlier on

http://svn.apache.org/viewvc?view=revision&revision=r1537442

It refers to a ServiceMix demo, though I haven't tested the demo.
I guess you'd register it the same way with cxfrs

Cheers, Sergey
On 17/10/14 16:19, atg roxx wrote:

> Hi Matt/Sergey,
>
> Thanks for replying.
>
> Sergey,
>
> I was not sure where and how to user your SwaggerFeature.. not sure where
> it will fit.
>
> Matt,
>
> In your approach too, could not see the use of camel cxfrs and also there
> are not camel routes to server the request.
>
> In Swagger config, could not see any resource location to search for
> resources class.
>
> Could you if possible , kindly let me know where how to use these in your
> sample program.
>
> -Regards,
> atg roxx
>
> On Fri, Oct 17, 2014 at 3:08 PM, Matt Raible <[hidden email]> wrote:
>
>> Here's how I did it.
>>
>> Application.java (to register Camel's servlet):
>> ----
>> import org.apache.camel.component.servlet.CamelHttpTransportServlet;
>> import org.springframework.boot.SpringApplication;
>> import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
>> import org.springframework.boot.builder.SpringApplicationBuilder;
>> import
>> org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
>> import
>> org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
>> import org.springframework.boot.context.embedded.ErrorPage;
>> import org.springframework.boot.context.embedded.ServletRegistrationBean;
>> import org.springframework.boot.context.web.SpringBootServletInitializer;
>> import org.springframework.context.annotation.Bean;
>> import org.springframework.context.annotation.ComponentScan;
>> import org.springframework.context.annotation.Configuration;
>> import org.springframework.http.HttpStatus;
>>
>> @Configuration
>> @ComponentScan
>> @EnableAutoConfiguration
>> public class Application extends SpringBootServletInitializer {
>>          private static final String CAMEL_URL_MAPPING = "/rest/*";
>>          private static final String CAMEL_SERVLET_NAME = "CamelServlet";
>>
>>          public static void main(String[] args) {
>>                  SpringApplication.run(Application.class, args);
>>          }
>>
>>          @Override
>>          protected SpringApplicationBuilder
>> configure(SpringApplicationBuilder application) {
>>                  return application.sources(Application.class);
>>          }
>>
>>          @Bean
>>          public ServletRegistrationBean servletRegistrationBean() {
>>                  ServletRegistrationBean registration =
>>                                  new ServletRegistrationBean(new
>> CamelHttpTransportServlet(), CAMEL_URL_MAPPING);
>>                  registration.setName(CAMEL_SERVLET_NAME);
>>                  return registration;
>>          }
>>
>>          @Bean
>>          public EmbeddedServletContainerCustomizer containerCustomizer() {
>>                  return new EmbeddedServletContainerCustomizer() {
>>                          @Override
>>                          public void
>> customize(ConfigurableEmbeddedServletContainer container) {
>>                                  ErrorPage error401Page = new
>> ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
>>                                  ErrorPage error404Page = new
>> ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
>>                                  ErrorPage error500Page = new
>> ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
>>
>>                                  container.addErrorPages(error401Page,
>> error404Page, error500Page);
>>                          }
>>                  };
>>          }
>> }
>>
>> SwaggerConfig.java:
>> ----
>> @Configuration
>> public class SwaggerConfig implements EnvironmentAware {
>>
>>      private RelaxedPropertyResolver propertyResolver;
>>
>>      @Override
>>      public void setEnvironment(Environment environment) {
>>          this.propertyResolver = new RelaxedPropertyResolver(environment,
>> "swagger.");
>>      }
>>
>>      /**
>>       * Swagger Camel Configuration
>>       */
>>      @Bean
>>      public ServletRegistrationBean swaggerServlet() {
>>          ServletRegistrationBean swagger = new ServletRegistrationBean(new
>> SpringRestSwaggerApiDeclarationServlet(), "/swagger/*");
>>          Map<String, String> params = new HashMap<>();
>>          params.put("base.path", "https://localhost:8443/rest");
>>          params.put("api.title", propertyResolver.getProperty("title"));
>>          params.put("api.description",
>> propertyResolver.getProperty("description"));
>>          params.put("api.termsOfServiceUrl",
>> propertyResolver.getProperty("termsOfServiceUrl"));
>>          params.put("api.license", propertyResolver.getProperty("license"));
>>          params.put("api.licenseUrl",
>> propertyResolver.getProperty("licenseUrl"));
>>          swagger.setInitParameters(params);
>>          return swagger;
>>      }
>>
>> }
>>
>> application.properties:
>> ----
>> # Swagger
>> swagger.title = My API
>> swagger.description = A description.
>> swagger.termsOfServiceUrl = http://yourcompany.com/terms.html
>> swagger.contact =
>> swagger.license = Apache 2.0
>> swagger.licenseUrl = http://www.apache.org/licenses/LICENSE-2.0.html
>>
>> Hope this helps,
>>
>> Matt
>>
>> On Fri, Oct 17, 2014 at 3:18 AM, atg roxx <[hidden email]> wrote:
>> Hi Team,
>>
>> I am using camel 2.14 and I am trying to expose rest endpoint using CXFRS
>> and want to use swagger to expose the rest api.
>>
>>
>> I am able to expose my rest service using cxfrs as described here :
>> http://camel.apache.org/cxfrs.html
>>
>> My application is not a web application, and I am using spring and spring
>> boot for my application.
>>
>> So I dont have web.xml in my case.
>>
>> Now for Integrating with Swagger, I looked at
>> http://camel.apache.org/swagger.html
>>
>> but it uses web.xml for it.
>>
>> Is there anyways we can do it without using web.xml.
>>
>> I looked at the exmple "camel-example-servlet-rest-tomcat" (
>> http://camel.apache.org/examples.html) explaining swagger integration with
>>   Camel, but here too web application is used for example i.e web.xml for
>> this integration.
>>
>>
>> Could anyone suggest how can we integrate swagger without use  of web.xml
>>
>>
>> -Cheers,
>> atg roxx
>>
>>
>>
>> --
>> 720-560-8460
>> http://raibledesigns.com
>> http://linkedin.com/in/mraible
>

Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

jack atwork
Hi,

Did you find any solution to this? As I'm faced with a similar problem?

I'm trying to setup swagger with the rest dsl and camel-jetty but there
appears to be no way to plug them together.

Am I missing something or is this camel-swagger component only intended for
traditional web applications (with a web.xml)?

As far as I can see the camel-swagger essentially provides a servlet that
discovers the api from the cametContext and a filter for cors.
Potentially these could be programmatically wired in but I don't see any
neat 'camel' solution to this.

Thanks

Jack


On 17 October 2014 17:44, Sergey Beryozkin <[hidden email]> wrote:

> This is a link Freeman kindly shared with me earlier on
>
> http://svn.apache.org/viewvc?view=revision&revision=r1537442
>
> It refers to a ServiceMix demo, though I haven't tested the demo.
> I guess you'd register it the same way with cxfrs
>
> Cheers, Sergey
>
> On 17/10/14 16:19, atg roxx wrote:
>
>> Hi Matt/Sergey,
>>
>> Thanks for replying.
>>
>> Sergey,
>>
>> I was not sure where and how to user your SwaggerFeature.. not sure where
>> it will fit.
>>
>> Matt,
>>
>> In your approach too, could not see the use of camel cxfrs and also there
>> are not camel routes to server the request.
>>
>> In Swagger config, could not see any resource location to search for
>> resources class.
>>
>> Could you if possible , kindly let me know where how to use these in your
>> sample program.
>>
>> -Regards,
>> atg roxx
>>
>> On Fri, Oct 17, 2014 at 3:08 PM, Matt Raible <[hidden email]>
>> wrote:
>>
>>  Here's how I did it.
>>>
>>> Application.java (to register Camel's servlet):
>>> ----
>>> import org.apache.camel.component.servlet.CamelHttpTransportServlet;
>>> import org.springframework.boot.SpringApplication;
>>> import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
>>> import org.springframework.boot.builder.SpringApplicationBuilder;
>>> import
>>> org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCon
>>> tainer;
>>> import
>>> org.springframework.boot.context.embedded.EmbeddedServletContainerCustom
>>> izer;
>>> import org.springframework.boot.context.embedded.ErrorPage;
>>> import org.springframework.boot.context.embedded.
>>> ServletRegistrationBean;
>>> import org.springframework.boot.context.web.
>>> SpringBootServletInitializer;
>>> import org.springframework.context.annotation.Bean;
>>> import org.springframework.context.annotation.ComponentScan;
>>> import org.springframework.context.annotation.Configuration;
>>> import org.springframework.http.HttpStatus;
>>>
>>> @Configuration
>>> @ComponentScan
>>> @EnableAutoConfiguration
>>> public class Application extends SpringBootServletInitializer {
>>>          private static final String CAMEL_URL_MAPPING = "/rest/*";
>>>          private static final String CAMEL_SERVLET_NAME = "CamelServlet";
>>>
>>>          public static void main(String[] args) {
>>>                  SpringApplication.run(Application.class, args);
>>>          }
>>>
>>>          @Override
>>>          protected SpringApplicationBuilder
>>> configure(SpringApplicationBuilder application) {
>>>                  return application.sources(Application.class);
>>>          }
>>>
>>>          @Bean
>>>          public ServletRegistrationBean servletRegistrationBean() {
>>>                  ServletRegistrationBean registration =
>>>                                  new ServletRegistrationBean(new
>>> CamelHttpTransportServlet(), CAMEL_URL_MAPPING);
>>>                  registration.setName(CAMEL_SERVLET_NAME);
>>>                  return registration;
>>>          }
>>>
>>>          @Bean
>>>          public EmbeddedServletContainerCustomizer
>>> containerCustomizer() {
>>>                  return new EmbeddedServletContainerCustomizer() {
>>>                          @Override
>>>                          public void
>>> customize(ConfigurableEmbeddedServletContainer container) {
>>>                                  ErrorPage error401Page = new
>>> ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
>>>                                  ErrorPage error404Page = new
>>> ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
>>>                                  ErrorPage error500Page = new
>>> ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
>>>
>>>                                  container.addErrorPages(error401Page,
>>> error404Page, error500Page);
>>>                          }
>>>                  };
>>>          }
>>> }
>>>
>>> SwaggerConfig.java:
>>> ----
>>> @Configuration
>>> public class SwaggerConfig implements EnvironmentAware {
>>>
>>>      private RelaxedPropertyResolver propertyResolver;
>>>
>>>      @Override
>>>      public void setEnvironment(Environment environment) {
>>>          this.propertyResolver = new RelaxedPropertyResolver(
>>> environment,
>>> "swagger.");
>>>      }
>>>
>>>      /**
>>>       * Swagger Camel Configuration
>>>       */
>>>      @Bean
>>>      public ServletRegistrationBean swaggerServlet() {
>>>          ServletRegistrationBean swagger = new
>>> ServletRegistrationBean(new
>>> SpringRestSwaggerApiDeclarationServlet(), "/swagger/*");
>>>          Map<String, String> params = new HashMap<>();
>>>          params.put("base.path", "https://localhost:8443/rest");
>>>          params.put("api.title", propertyResolver.getProperty("title"));
>>>          params.put("api.description",
>>> propertyResolver.getProperty("description"));
>>>          params.put("api.termsOfServiceUrl",
>>> propertyResolver.getProperty("termsOfServiceUrl"));
>>>          params.put("api.license", propertyResolver.getProperty("
>>> license"));
>>>          params.put("api.licenseUrl",
>>> propertyResolver.getProperty("licenseUrl"));
>>>          swagger.setInitParameters(params);
>>>          return swagger;
>>>      }
>>>
>>> }
>>>
>>> application.properties:
>>> ----
>>> # Swagger
>>> swagger.title = My API
>>> swagger.description = A description.
>>> swagger.termsOfServiceUrl = http://yourcompany.com/terms.html
>>> swagger.contact =
>>> swagger.license = Apache 2.0
>>> swagger.licenseUrl = http://www.apache.org/licenses/LICENSE-2.0.html
>>>
>>> Hope this helps,
>>>
>>> Matt
>>>
>>> On Fri, Oct 17, 2014 at 3:18 AM, atg roxx <[hidden email]> wrote:
>>> Hi Team,
>>>
>>> I am using camel 2.14 and I am trying to expose rest endpoint using CXFRS
>>> and want to use swagger to expose the rest api.
>>>
>>>
>>> I am able to expose my rest service using cxfrs as described here :
>>> http://camel.apache.org/cxfrs.html
>>>
>>> My application is not a web application, and I am using spring and spring
>>> boot for my application.
>>>
>>> So I dont have web.xml in my case.
>>>
>>> Now for Integrating with Swagger, I looked at
>>> http://camel.apache.org/swagger.html
>>>
>>> but it uses web.xml for it.
>>>
>>> Is there anyways we can do it without using web.xml.
>>>
>>> I looked at the exmple "camel-example-servlet-rest-tomcat" (
>>> http://camel.apache.org/examples.html) explaining swagger integration
>>> with
>>>   Camel, but here too web application is used for example i.e web.xml for
>>> this integration.
>>>
>>>
>>> Could anyone suggest how can we integrate swagger without use  of web.xml
>>>
>>>
>>> -Cheers,
>>> atg roxx
>>>
>>>
>>>
>>> --
>>> 720-560-8460
>>> http://raibledesigns.com
>>> http://linkedin.com/in/mraible
>>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

Matt Raible
I created an example application to show how I got Camel's REST + Swagger to work together in a Spring environment with no web.xml.

https://github.com/mraible/camel-rest-swagger

Specifically, see Application.java (for configuring the CamelServlet) and SwaggerConfig.java (for the Swagger servlet):

https://github.com/mraible/camel-rest-swagger/blob/master/src/main/java/com/raibledesigns/camel/Application.java
https://github.com/mraible/camel-rest-swagger/blob/master/src/main/java/com/raibledesigns/camel/config/SwaggerConfig.java

Hope this helps,

Matt

On Oct 22, 2014, at 10:38 AM, jack atwork <[hidden email]> wrote:

> Hi,
>
> Did you find any solution to this? As I'm faced with a similar problem?
>
> I'm trying to setup swagger with the rest dsl and camel-jetty but there
> appears to be no way to plug them together.
>
> Am I missing something or is this camel-swagger component only intended for
> traditional web applications (with a web.xml)?
>
> As far as I can see the camel-swagger essentially provides a servlet that
> discovers the api from the cametContext and a filter for cors.
> Potentially these could be programmatically wired in but I don't see any
> neat 'camel' solution to this.
>
> Thanks
>
> Jack
>
>
> On 17 October 2014 17:44, Sergey Beryozkin <[hidden email]> wrote:
>
>> This is a link Freeman kindly shared with me earlier on
>>
>> http://svn.apache.org/viewvc?view=revision&revision=r1537442
>>
>> It refers to a ServiceMix demo, though I haven't tested the demo.
>> I guess you'd register it the same way with cxfrs
>>
>> Cheers, Sergey
>>
>> On 17/10/14 16:19, atg roxx wrote:
>>
>>> Hi Matt/Sergey,
>>>
>>> Thanks for replying.
>>>
>>> Sergey,
>>>
>>> I was not sure where and how to user your SwaggerFeature.. not sure where
>>> it will fit.
>>>
>>> Matt,
>>>
>>> In your approach too, could not see the use of camel cxfrs and also there
>>> are not camel routes to server the request.
>>>
>>> In Swagger config, could not see any resource location to search for
>>> resources class.
>>>
>>> Could you if possible , kindly let me know where how to use these in your
>>> sample program.
>>>
>>> -Regards,
>>> atg roxx
>>>
>>> On Fri, Oct 17, 2014 at 3:08 PM, Matt Raible <[hidden email]>
>>> wrote:
>>>
>>> Here's how I did it.
>>>>
>>>> Application.java (to register Camel's servlet):
>>>> ----
>>>> import org.apache.camel.component.servlet.CamelHttpTransportServlet;
>>>> import org.springframework.boot.SpringApplication;
>>>> import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
>>>> import org.springframework.boot.builder.SpringApplicationBuilder;
>>>> import
>>>> org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCon
>>>> tainer;
>>>> import
>>>> org.springframework.boot.context.embedded.EmbeddedServletContainerCustom
>>>> izer;
>>>> import org.springframework.boot.context.embedded.ErrorPage;
>>>> import org.springframework.boot.context.embedded.
>>>> ServletRegistrationBean;
>>>> import org.springframework.boot.context.web.
>>>> SpringBootServletInitializer;
>>>> import org.springframework.context.annotation.Bean;
>>>> import org.springframework.context.annotation.ComponentScan;
>>>> import org.springframework.context.annotation.Configuration;
>>>> import org.springframework.http.HttpStatus;
>>>>
>>>> @Configuration
>>>> @ComponentScan
>>>> @EnableAutoConfiguration
>>>> public class Application extends SpringBootServletInitializer {
>>>>         private static final String CAMEL_URL_MAPPING = "/rest/*";
>>>>         private static final String CAMEL_SERVLET_NAME = "CamelServlet";
>>>>
>>>>         public static void main(String[] args) {
>>>>                 SpringApplication.run(Application.class, args);
>>>>         }
>>>>
>>>>         @Override
>>>>         protected SpringApplicationBuilder
>>>> configure(SpringApplicationBuilder application) {
>>>>                 return application.sources(Application.class);
>>>>         }
>>>>
>>>>         @Bean
>>>>         public ServletRegistrationBean servletRegistrationBean() {
>>>>                 ServletRegistrationBean registration =
>>>>                                 new ServletRegistrationBean(new
>>>> CamelHttpTransportServlet(), CAMEL_URL_MAPPING);
>>>>                 registration.setName(CAMEL_SERVLET_NAME);
>>>>                 return registration;
>>>>         }
>>>>
>>>>         @Bean
>>>>         public EmbeddedServletContainerCustomizer
>>>> containerCustomizer() {
>>>>                 return new EmbeddedServletContainerCustomizer() {
>>>>                         @Override
>>>>                         public void
>>>> customize(ConfigurableEmbeddedServletContainer container) {
>>>>                                 ErrorPage error401Page = new
>>>> ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
>>>>                                 ErrorPage error404Page = new
>>>> ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
>>>>                                 ErrorPage error500Page = new
>>>> ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
>>>>
>>>>                                 container.addErrorPages(error401Page,
>>>> error404Page, error500Page);
>>>>                         }
>>>>                 };
>>>>         }
>>>> }
>>>>
>>>> SwaggerConfig.java:
>>>> ----
>>>> @Configuration
>>>> public class SwaggerConfig implements EnvironmentAware {
>>>>
>>>>     private RelaxedPropertyResolver propertyResolver;
>>>>
>>>>     @Override
>>>>     public void setEnvironment(Environment environment) {
>>>>         this.propertyResolver = new RelaxedPropertyResolver(
>>>> environment,
>>>> "swagger.");
>>>>     }
>>>>
>>>>     /**
>>>>      * Swagger Camel Configuration
>>>>      */
>>>>     @Bean
>>>>     public ServletRegistrationBean swaggerServlet() {
>>>>         ServletRegistrationBean swagger = new
>>>> ServletRegistrationBean(new
>>>> SpringRestSwaggerApiDeclarationServlet(), "/swagger/*");
>>>>         Map<String, String> params = new HashMap<>();
>>>>         params.put("base.path", "https://localhost:8443/rest");
>>>>         params.put("api.title", propertyResolver.getProperty("title"));
>>>>         params.put("api.description",
>>>> propertyResolver.getProperty("description"));
>>>>         params.put("api.termsOfServiceUrl",
>>>> propertyResolver.getProperty("termsOfServiceUrl"));
>>>>         params.put("api.license", propertyResolver.getProperty("
>>>> license"));
>>>>         params.put("api.licenseUrl",
>>>> propertyResolver.getProperty("licenseUrl"));
>>>>         swagger.setInitParameters(params);
>>>>         return swagger;
>>>>     }
>>>>
>>>> }
>>>>
>>>> application.properties:
>>>> ----
>>>> # Swagger
>>>> swagger.title = My API
>>>> swagger.description = A description.
>>>> swagger.termsOfServiceUrl = http://yourcompany.com/terms.html
>>>> swagger.contact =
>>>> swagger.license = Apache 2.0
>>>> swagger.licenseUrl = http://www.apache.org/licenses/LICENSE-2.0.html
>>>>
>>>> Hope this helps,
>>>>
>>>> Matt
>>>>
>>>> On Fri, Oct 17, 2014 at 3:18 AM, atg roxx <[hidden email]> wrote:
>>>> Hi Team,
>>>>
>>>> I am using camel 2.14 and I am trying to expose rest endpoint using CXFRS
>>>> and want to use swagger to expose the rest api.
>>>>
>>>>
>>>> I am able to expose my rest service using cxfrs as described here :
>>>> http://camel.apache.org/cxfrs.html
>>>>
>>>> My application is not a web application, and I am using spring and spring
>>>> boot for my application.
>>>>
>>>> So I dont have web.xml in my case.
>>>>
>>>> Now for Integrating with Swagger, I looked at
>>>> http://camel.apache.org/swagger.html
>>>>
>>>> but it uses web.xml for it.
>>>>
>>>> Is there anyways we can do it without using web.xml.
>>>>
>>>> I looked at the exmple "camel-example-servlet-rest-tomcat" (
>>>> http://camel.apache.org/examples.html) explaining swagger integration
>>>> with
>>>>  Camel, but here too web application is used for example i.e web.xml for
>>>> this integration.
>>>>
>>>>
>>>> Could anyone suggest how can we integrate swagger without use  of web.xml
>>>>
>>>>
>>>> -Cheers,
>>>> atg roxx
>>>>
>>>>
>>>>
>>>> --
>>>> 720-560-8460
>>>> http://raibledesigns.com
>>>> http://linkedin.com/in/mraible
>>>>
>>>
>>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

atg roxx
Hi Matt,


I will check your solution and will let you know whether it works or not.



Jack,

I have not found any straight forward solution for it.

The approach which I am using right now is  to use  swagger maven plugin (
http://www.github.com/kongchen/swagger-maven-plugin) to generate swagger
json files at compile time.

Also configure my application to send this JSON (service.json) generated as
response to http://localhost:8080/swagger  url.

Now using swagger ui display that json information. Note : This swagger ui
will run as a independent server.

So working steps are :

!) Build and launch your application (after making use of Kongchen json
pluging).

2) Launch swagger ui server. and provide your application swagger url to
it( url on which your application will return server.json).


This will do the trick.

-Cheers,
atg roxx

On Wed, Oct 22, 2014 at 6:34 PM, Matt Raible <[hidden email]> wrote:

> I created an example application to show how I got Camel's REST + Swagger
> to work together in a Spring environment with no web.xml.
>
> https://github.com/mraible/camel-rest-swagger
>
> Specifically, see Application.java (for configuring the CamelServlet) and
> SwaggerConfig.java (for the Swagger servlet):
>
>
> https://github.com/mraible/camel-rest-swagger/blob/master/src/main/java/com/raibledesigns/camel/Application.java
>
> https://github.com/mraible/camel-rest-swagger/blob/master/src/main/java/com/raibledesigns/camel/config/SwaggerConfig.java
>
> Hope this helps,
>
> Matt
>
> On Oct 22, 2014, at 10:38 AM, jack atwork <[hidden email]> wrote:
>
> > Hi,
> >
> > Did you find any solution to this? As I'm faced with a similar problem?
> >
> > I'm trying to setup swagger with the rest dsl and camel-jetty but there
> > appears to be no way to plug them together.
> >
> > Am I missing something or is this camel-swagger component only intended
> for
> > traditional web applications (with a web.xml)?
> >
> > As far as I can see the camel-swagger essentially provides a servlet that
> > discovers the api from the cametContext and a filter for cors.
> > Potentially these could be programmatically wired in but I don't see any
> > neat 'camel' solution to this.
> >
> > Thanks
> >
> > Jack
> >
> >
> > On 17 October 2014 17:44, Sergey Beryozkin <[hidden email]> wrote:
> >
> >> This is a link Freeman kindly shared with me earlier on
> >>
> >> http://svn.apache.org/viewvc?view=revision&revision=r1537442
> >>
> >> It refers to a ServiceMix demo, though I haven't tested the demo.
> >> I guess you'd register it the same way with cxfrs
> >>
> >> Cheers, Sergey
> >>
> >> On 17/10/14 16:19, atg roxx wrote:
> >>
> >>> Hi Matt/Sergey,
> >>>
> >>> Thanks for replying.
> >>>
> >>> Sergey,
> >>>
> >>> I was not sure where and how to user your SwaggerFeature.. not sure
> where
> >>> it will fit.
> >>>
> >>> Matt,
> >>>
> >>> In your approach too, could not see the use of camel cxfrs and also
> there
> >>> are not camel routes to server the request.
> >>>
> >>> In Swagger config, could not see any resource location to search for
> >>> resources class.
> >>>
> >>> Could you if possible , kindly let me know where how to use these in
> your
> >>> sample program.
> >>>
> >>> -Regards,
> >>> atg roxx
> >>>
> >>> On Fri, Oct 17, 2014 at 3:08 PM, Matt Raible <[hidden email]>
> >>> wrote:
> >>>
> >>> Here's how I did it.
> >>>>
> >>>> Application.java (to register Camel's servlet):
> >>>> ----
> >>>> import org.apache.camel.component.servlet.CamelHttpTransportServlet;
> >>>> import org.springframework.boot.SpringApplication;
> >>>> import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
> >>>> import org.springframework.boot.builder.SpringApplicationBuilder;
> >>>> import
> >>>>
> org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCon
> >>>> tainer;
> >>>> import
> >>>>
> org.springframework.boot.context.embedded.EmbeddedServletContainerCustom
> >>>> izer;
> >>>> import org.springframework.boot.context.embedded.ErrorPage;
> >>>> import org.springframework.boot.context.embedded.
> >>>> ServletRegistrationBean;
> >>>> import org.springframework.boot.context.web.
> >>>> SpringBootServletInitializer;
> >>>> import org.springframework.context.annotation.Bean;
> >>>> import org.springframework.context.annotation.ComponentScan;
> >>>> import org.springframework.context.annotation.Configuration;
> >>>> import org.springframework.http.HttpStatus;
> >>>>
> >>>> @Configuration
> >>>> @ComponentScan
> >>>> @EnableAutoConfiguration
> >>>> public class Application extends SpringBootServletInitializer {
> >>>>         private static final String CAMEL_URL_MAPPING = "/rest/*";
> >>>>         private static final String CAMEL_SERVLET_NAME =
> "CamelServlet";
> >>>>
> >>>>         public static void main(String[] args) {
> >>>>                 SpringApplication.run(Application.class, args);
> >>>>         }
> >>>>
> >>>>         @Override
> >>>>         protected SpringApplicationBuilder
> >>>> configure(SpringApplicationBuilder application) {
> >>>>                 return application.sources(Application.class);
> >>>>         }
> >>>>
> >>>>         @Bean
> >>>>         public ServletRegistrationBean servletRegistrationBean() {
> >>>>                 ServletRegistrationBean registration =
> >>>>                                 new ServletRegistrationBean(new
> >>>> CamelHttpTransportServlet(), CAMEL_URL_MAPPING);
> >>>>                 registration.setName(CAMEL_SERVLET_NAME);
> >>>>                 return registration;
> >>>>         }
> >>>>
> >>>>         @Bean
> >>>>         public EmbeddedServletContainerCustomizer
> >>>> containerCustomizer() {
> >>>>                 return new EmbeddedServletContainerCustomizer() {
> >>>>                         @Override
> >>>>                         public void
> >>>> customize(ConfigurableEmbeddedServletContainer container) {
> >>>>                                 ErrorPage error401Page = new
> >>>> ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
> >>>>                                 ErrorPage error404Page = new
> >>>> ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
> >>>>                                 ErrorPage error500Page = new
> >>>> ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
> >>>>
> >>>>                                 container.addErrorPages(error401Page,
> >>>> error404Page, error500Page);
> >>>>                         }
> >>>>                 };
> >>>>         }
> >>>> }
> >>>>
> >>>> SwaggerConfig.java:
> >>>> ----
> >>>> @Configuration
> >>>> public class SwaggerConfig implements EnvironmentAware {
> >>>>
> >>>>     private RelaxedPropertyResolver propertyResolver;
> >>>>
> >>>>     @Override
> >>>>     public void setEnvironment(Environment environment) {
> >>>>         this.propertyResolver = new RelaxedPropertyResolver(
> >>>> environment,
> >>>> "swagger.");
> >>>>     }
> >>>>
> >>>>     /**
> >>>>      * Swagger Camel Configuration
> >>>>      */
> >>>>     @Bean
> >>>>     public ServletRegistrationBean swaggerServlet() {
> >>>>         ServletRegistrationBean swagger = new
> >>>> ServletRegistrationBean(new
> >>>> SpringRestSwaggerApiDeclarationServlet(), "/swagger/*");
> >>>>         Map<String, String> params = new HashMap<>();
> >>>>         params.put("base.path", "https://localhost:8443/rest");
> >>>>         params.put("api.title",
> propertyResolver.getProperty("title"));
> >>>>         params.put("api.description",
> >>>> propertyResolver.getProperty("description"));
> >>>>         params.put("api.termsOfServiceUrl",
> >>>> propertyResolver.getProperty("termsOfServiceUrl"));
> >>>>         params.put("api.license", propertyResolver.getProperty("
> >>>> license"));
> >>>>         params.put("api.licenseUrl",
> >>>> propertyResolver.getProperty("licenseUrl"));
> >>>>         swagger.setInitParameters(params);
> >>>>         return swagger;
> >>>>     }
> >>>>
> >>>> }
> >>>>
> >>>> application.properties:
> >>>> ----
> >>>> # Swagger
> >>>> swagger.title = My API
> >>>> swagger.description = A description.
> >>>> swagger.termsOfServiceUrl = http://yourcompany.com/terms.html
> >>>> swagger.contact =
> >>>> swagger.license = Apache 2.0
> >>>> swagger.licenseUrl = http://www.apache.org/licenses/LICENSE-2.0.html
> >>>>
> >>>> Hope this helps,
> >>>>
> >>>> Matt
> >>>>
> >>>> On Fri, Oct 17, 2014 at 3:18 AM, atg roxx <[hidden email]> wrote:
> >>>> Hi Team,
> >>>>
> >>>> I am using camel 2.14 and I am trying to expose rest endpoint using
> CXFRS
> >>>> and want to use swagger to expose the rest api.
> >>>>
> >>>>
> >>>> I am able to expose my rest service using cxfrs as described here :
> >>>> http://camel.apache.org/cxfrs.html
> >>>>
> >>>> My application is not a web application, and I am using spring and
> spring
> >>>> boot for my application.
> >>>>
> >>>> So I dont have web.xml in my case.
> >>>>
> >>>> Now for Integrating with Swagger, I looked at
> >>>> http://camel.apache.org/swagger.html
> >>>>
> >>>> but it uses web.xml for it.
> >>>>
> >>>> Is there anyways we can do it without using web.xml.
> >>>>
> >>>> I looked at the exmple "camel-example-servlet-rest-tomcat" (
> >>>> http://camel.apache.org/examples.html) explaining swagger integration
> >>>> with
> >>>>  Camel, but here too web application is used for example i.e web.xml
> for
> >>>> this integration.
> >>>>
> >>>>
> >>>> Could anyone suggest how can we integrate swagger without use  of
> web.xml
> >>>>
> >>>>
> >>>> -Cheers,
> >>>> atg roxx
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> 720-560-8460
> >>>> http://raibledesigns.com
> >>>> http://linkedin.com/in/mraible
> >>>>
> >>>
> >>>
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

gquintana
Hello,

As strange as it may seem, the SwaggerFeature plays well with pure CXFRS, but doesn't with Camel CXFRS:
    <bean id="swaggerFeature" class="org.apache.cxf.jaxrs.swagger.SwaggerFeature">
        <property name="resourcePackage" value="com.mycompany.myapp.customer"/>
        <property name="version" value="1.0.0"/>
        <property name="title" value="MyApp"/>
    </bean>
    <bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>

    <!-- Pure CXFRS -->
    <cxf-rs:server address="http://localhost:9000/pure" serviceClass="com.mycompany.myapp.customer.CustomerResource">
        <cxf-rs:providers>
            <ref bean="jsonProvider" />
        </cxf-rs:providers>
        <cxf-rs:features>
            <ref bean="swaggerFeature" />
        </cxf-rs:features>
    </cxf-rs:server>

    <!-- Camel CXFRS -->
    <cxf:rsServer id="hotelResource"
                  address="http://localhost:9000/camel"
                  serviceClass="com.mycompany.myapp.customer.CustomerResource">
        <cxf:providers>
            <ref bean="jsonProvider" />
        </cxf:providers>
        <cxf:features>
            <ref bean="swaggerFeature" />
        </cxf:features>
    </cxf:rsServer>

In the first case (<cxfrs:server>): the ApiListingResourceJSON does it's job and return the swagger JSON.

In the second case (<camel-cxfrs:rsServer>), the ApiListingResourceJSON is not called, the request is not intercepted and produces a message wich enters in the Camel route. The /api-docs request doesn't throw a 404 error though.

From the Camel route configuration, is there way to tell Camel not to handle some requests and let CXFRS do it's job?

Gérald
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

Sergey Beryozkin
Hi

You can probably support /camel/api-docs queries and have a pre-matching
ContainerRequestFilter adapt camel/api-docs to /api-docs

Would that work ?

Cheers, Sergey
On 11/12/14 14:32, gquintana wrote:

> Hello,
>
> As strange as it may seem, the SwaggerFeature plays well with pure CXFRS,
> but doesn't with Camel CXFRS:
>
>
> In the first case (<cxfrs:server>): the ApiListingResourceJSON does it's job
> and return the swagger JSON.
>
> In the second case (<camel-cxfrs:rsServer>), the ApiListingResourceJSON is
> not called, the request is not intercepted and produces a message wich
> enters in the Camel route. The /api-docs request doesn't throw a 404 error
> though.
>
>  From the Camel route configuration, is there way to tell Camel not to handle
> some requests and let CXFRS do it's job?
>
> Gérald
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-cxfrs-with-swagger-tp5757720p5760576.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

gquintana
I don't fully understand your proposal.

After digging bit, I came to the conclusion that it wasn't the server declaration which was different, but the fact that the consumer was installing the CxfRsInvoker in the server which changed everything. The CxfRsInvoker swallows all requests to produce Camel exchanges and never calls the registered service beans.

Gérald
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

Sergey Beryozkin
On 11/12/14 20:12, gquintana wrote:
> I don't fully understand your proposal.
I thought the problem was /api-docs was not reaching the  endpoint at
all, so the idea was to make sure it is covered by a "/camel" URI
sub-space, part of the endpoint address but then redirect to the swagger
endpoint...
>
> After digging bit, I came to the conclusion that it wasn't the server
> declaration which was different, but the fact that the consumer was
> installing the CxfRsInvoker in the server which changed everything. The
> CxfRsInvoker swallows all requests to produce Camel exchanges and never
> calls the registered service beans.
>
I think a cxf swagger feature may need to be updated for it to run as a
pre-matching filter so that it can directly invoke on the swagger
resource. Perhaps a Swagger resource itself should implement
ContainerRequestFilter optionally... That can be investigated further on
the cxf end.
The other long pending enhancement that needs to be implemented asap,
CXFRS should ship CXF interceptors which can let a regular CXF endpoint
seamlessly integrate into a route - I'll try to prioritize and create a
patch

Sergey

> Gérald
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-cxfrs-with-swagger-tp5757720p5760599.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: camel cxfrs with swagger.

Sergey Beryozkin
Andriy Redko (CXF colleague of mine) and myself worked on getting CXF
SwaggerFeature running as JAX_RS 2.0 filter - this should make sure it
is effective with cxfrs too - you may want to experiment with updating
the cxfrs dependencies to CXF 3.0.4-SNAPSHOT

Cheers, Sergey

On 11/12/14 21:53, Sergey Beryozkin wrote:

> On 11/12/14 20:12, gquintana wrote:
>> I don't fully understand your proposal.
> I thought the problem was /api-docs was not reaching the  endpoint at
> all, so the idea was to make sure it is covered by a "/camel" URI
> sub-space, part of the endpoint address but then redirect to the swagger
> endpoint...
>>
>> After digging bit, I came to the conclusion that it wasn't the server
>> declaration which was different, but the fact that the consumer was
>> installing the CxfRsInvoker in the server which changed everything. The
>> CxfRsInvoker swallows all requests to produce Camel exchanges and never
>> calls the registered service beans.
>>
> I think a cxf swagger feature may need to be updated for it to run as a
> pre-matching filter so that it can directly invoke on the swagger
> resource. Perhaps a Swagger resource itself should implement
> ContainerRequestFilter optionally... That can be investigated further on
> the cxf end.
> The other long pending enhancement that needs to be implemented asap,
> CXFRS should ship CXF interceptors which can let a regular CXF endpoint
> seamlessly integrate into a route - I'll try to prioritize and create a
> patch
>
> Sergey
>
>> Gérald
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/camel-cxfrs-with-swagger-tp5757720p5760599.html
>>
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>