camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: REST, Swagger and zombies
Date Thu, 09 Mar 2017 13:14:46 GMT
Hi

I dont think any Camel users fancy writing 10 lines to setup a
component to call a rest endpoint.
I dont think what you do is simple. Although its possible.

Maybe if you can get it down a syntax as

      rest-swagger:path:swaggerOperationId

where path can be optional, and if omitted, then its read from
component / rest configuration (maybe the context-path option, or
introduce a new producerContextPath if we need to)

In your example you can just do "rest-swagger:v2:getPetById"


And if you want to configure the path you can do that on the component
level (although requires a bit of java code)

RestSwaggerComponent ...
  component.setPath("v2")

... but spring boot users can configure it using spring boot style in
application.properties

camel.component.rest-swagger.path = v2


And the componentName=underow is auto discovered afair. And if not you
can set it on rest configuration (producer component).










On Thu, Mar 9, 2017 at 1:42 PM, Zoran Regvart <zoran@regvart.com> wrote:
> Hi Cameleers,
> I'm thinking of reopening CAMEL-10932[1]: the REST Swagger component,
> I would like to see support for something as simple like
> `rest-swagger:operation`, where operation would be from a Swagger
> specification. Operation ids are guaranteed to be unique by Swagger
> specification.
>
> I've got this working better than in the initial PR i submitted for
> review -- now it delegates to RestEndpoint much in the same manner
> RestProducerFactory implementations delegate to their own endpoints.
>
> The thing that buggs me is passing http component specific or even
> rest component specific properties from this new component. Now I have
> a Map of properties to pass and I'm using
> DefaultEndpoint::setProperties to propagate them to RestEndpoint.
>
> But I guess, this is not helping tooling in any way as it has no way
> of knowing what properties are supported. So, is there a better way of
> doing this? I don't want to duplicate properties getters/setters and
> then have to maintain them in two places.
>
> Oh, and I have an example of usage, but it should be as simple as:
>
>     final RestConfiguration restConfiguration = new RestConfiguration();
>     restConfiguration.setHost("http://petstore.swagger.io");
>     context.setRestConfiguration(restConfiguration);
>
>     final RestSwaggerComponent petstore = new
> RestSwaggerComponent(camelContext);
>     final Map<String, Object> parameters = new HashMap<>();
>     parameters.put("path", "/v2");
>     parameters.put("componentName", "undertow"); // or any other
> RestProducerFactory component
>     petstore.setParameters(parameters);
>     context.addComponent("petstore", petstore);
>     //...
>     template.requestBodyAndHeader("petstore:getPetById", null, "petId", 1);
>
> thanks, and sorry for being long winded
>
> zoran
>
> [1] https://issues.apache.org/jira/browse/CAMEL-10932
> --
> Zoran Regvart



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

Mime
View raw message