Hi,

i have set this up via the Java DSL. the rest configuration looks like this:

  restConfiguration()
                .component("netty4-http")
                .host("localhost")
                .port(settings.getInteger(Setting.REST_PORT))
                .bindingMode(RestBindingMode.json)
                .enableCORS(true)
                .dataFormatProperty("prettyPrint", "false")
                .skipBindingOnErrorCode(false)
                .contextPath("/")
                .apiContextPath("/api-doc")
                .apiProperty("api.title", "User API")
                .apiProperty("api.version", "1.2.3")
                .apiProperty("cors", "true");

Comparing this to your example i do not see a relevant difference, but i
But the result which i get when I use swagger-ui is:

{
  "error": "no response from server"
}


if I use the generated curl request i get the expected response.

Greetings

Gerald Mixa



2016-04-25 19:05 GMT+02:00 Claus Ibsen <claus.ib...@gmail.com>:

> Hi
>
> Yeah you need to enable cors in restConfiguration and due to a bug in
> 2.17.0, you need to set the cors=true as a apiProperty as well.
>
> See here for an example
>
> https://github.com/camelinaction/camelinaction2/blob/master/chapter10/swagger-ui/src/main/resources/camel.xml#L47
>
> On Mon, Apr 25, 2016 at 5:43 PM, Gerald Mixa <gerald.m...@gmail.com>
> wrote:
> > Hello all,
> >
> > i want to use swagger to document my rest api which run in camel 2.17.0
> as
> > standalone application.
> > This seems to work fine. Unfortunately its not possible to test the api
> via
> > the swagger ui.
> > On http://camel.apache.org/swagger-java.html i found the information
> that i
> > should set up and configure a RestSwaggerCorsFilter. This is done via
> > web.xml. But as i am running standalone this filter cannot be configured
> > via web.xml. Is there another way to configure a cors filter which works
> in
> > standalone mode too?
> >
> > Greetings
> >
> > Gerald Mixa
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Reply via email to