Camel and Swagger API *client* code

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

Camel and Swagger API *client* code

Ron Cecchini
I'm taking a shot here...

I'm new to Swagger.

I see that Camel has integration for generating Swagger APIs.

But what about *reading* someone else's API and using their schemas in my routes?

I'm looking at Swagger Codegen to see how to generate the client code...  But given Camel's infinite awesomeness, I was wondering if Camel or anyone has basically automated the process so that, say, at start up you can dynamically grab someone's API and use that to parse data from their endpoints, etc.

Thanks and have a great weekend everyone.
Reply | Threaded
Open this post in threaded view
|

Re: Camel and Swagger API *client* code

Claus Ibsen-2
Hi

Maybe something like the rest-swagger component
https://camel.apache.org/components/latest/rest-swagger-component.html

However this is for Camel to call an existing REST service by
referring to the swagger api of the service.

On Fri, Nov 8, 2019 at 10:17 PM Ron Cecchini <[hidden email]> wrote:

>
> I'm taking a shot here...
>
> I'm new to Swagger.
>
> I see that Camel has integration for generating Swagger APIs.
>
> But what about *reading* someone else's API and using their schemas in my routes?
>
> I'm looking at Swagger Codegen to see how to generate the client code...  But given Camel's infinite awesomeness, I was wondering if Camel or anyone has basically automated the process so that, say, at start up you can dynamically grab someone's API and use that to parse data from their endpoints, etc.
>
> Thanks and have a great weekend everyone.



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Camel and Swagger API *client* code

Ron Cecchini
Hi, Claus.  Thanks for your response.

The Camel "rest-swagger" looks awesome but unfortunately I don't think I can use it, because what I actually need are the data models created from the Swagger OpenAPI specs.

And as it turns out, Maven's "swagger-codegen-maven-plugin" is precisely what I need.  I misspoke earlier when I said I wanted to dynamically pull in the API at startup.  I was just trying to avoid a manual CodeGen ("swagger-codegen-cli") step before compiling.

But with the Maven plugin I can grab the API and generate the models at compile time - which is perfectly suitable for my needs.  And it's great that the plugin lets you specify either a URL or a local JSON file (which is what I'll end up using), and it lets you generate exactly the models you need (instead of all of them).

I'm sure this is all old hat to you guys, but I'm new to it...

Thank you again.

Ron

...

FWIW: I got my tech lead excited about Camel and Spring Boot and he gave me the go ahead.  I'm creating a Spring Boot + Camel pipeline with a scalable Ingest "head" where multiple rest components will each hit a different endpoint to get a JSON array of hundreds or thousands of elements.  I'll then use Camel to split the array, start some Camel parallelProcessing() or threads() or whatever, convert each JSON to one of the model POJOs created by Swagger, then convert each model to a custom model, and write it to a Kafka topic to feed the rest of the pipeline.  (or maybe it's better for Ingest to just write the JSON elements to Kafka, and let the other side of the pipeline do the JSON transforming...)  Anyway, should be pretty neat, and it'll be much less code than what they currently have.  It's pretty straight forward stuff you guys do all the time, but it'll be my biggest Camel implementation yet, and I'm glad I'm getting to showcase Camel as being something other than a tool to jus
 t "read from a JMS and write to a JMS".

> On November 8, 2019 at 4:24 PM Claus Ibsen <[hidden email]> wrote:
>
>
> Hi
>
> Maybe something like the rest-swagger component
> https://camel.apache.org/components/latest/rest-swagger-component.html
>
> However this is for Camel to call an existing REST service by
> referring to the swagger api of the service.
>
> On Fri, Nov 8, 2019 at 10:17 PM Ron Cecchini <[hidden email]> wrote:
> >
> > I'm taking a shot here...
> >
> > I'm new to Swagger.
> >
> > I see that Camel has integration for generating Swagger APIs.
> >
> > But what about *reading* someone else's API and using their schemas in my routes?
> >
> > I'm looking at Swagger Codegen to see how to generate the client code...  But given Camel's infinite awesomeness, I was wondering if Camel or anyone has basically automated the process so that, say, at start up you can dynamically grab someone's API and use that to parse data from their endpoints, etc.
> >
> > Thanks and have a great weekend everyone.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Camel and Swagger API *client* code

Claus Ibsen-2
Hi Ron

Good to hear that you can find a solution, and thats its a step up
with your Camel adventure.

The community is here if you need help or want to discuss something.
And then mind Camel 3 is around the corner so that brings you new
adventures too ;)


On Sat, Nov 9, 2019 at 7:37 AM Ron Cecchini <[hidden email]> wrote:

>
> Hi, Claus.  Thanks for your response.
>
> The Camel "rest-swagger" looks awesome but unfortunately I don't think I can use it, because what I actually need are the data models created from the Swagger OpenAPI specs.
>
> And as it turns out, Maven's "swagger-codegen-maven-plugin" is precisely what I need.  I misspoke earlier when I said I wanted to dynamically pull in the API at startup.  I was just trying to avoid a manual CodeGen ("swagger-codegen-cli") step before compiling.
>
> But with the Maven plugin I can grab the API and generate the models at compile time - which is perfectly suitable for my needs.  And it's great that the plugin lets you specify either a URL or a local JSON file (which is what I'll end up using), and it lets you generate exactly the models you need (instead of all of them).
>
> I'm sure this is all old hat to you guys, but I'm new to it...
>
> Thank you again.
>
> Ron
>
> ...
>
> FWIW: I got my tech lead excited about Camel and Spring Boot and he gave me the go ahead.  I'm creating a Spring Boot + Camel pipeline with a scalable Ingest "head" where multiple rest components will each hit a different endpoint to get a JSON array of hundreds or thousands of elements.  I'll then use Camel to split the array, start some Camel parallelProcessing() or threads() or whatever, convert each JSON to one of the model POJOs created by Swagger, then convert each model to a custom model, and write it to a Kafka topic to feed the rest of the pipeline.  (or maybe it's better for Ingest to just write the JSON elements to Kafka, and let the other side of the pipeline do the JSON transforming...)  Anyway, should be pretty neat, and it'll be much less code than what they currently have.  It's pretty straight forward stuff you guys do all the time, but it'll be my biggest Camel implementation yet, and I'm glad I'm getting to showcase Camel as being something other than a tool to jus
>  t "read from a JMS and write to a JMS".
>
> > On November 8, 2019 at 4:24 PM Claus Ibsen <[hidden email]> wrote:
> >
> >
> > Hi
> >
> > Maybe something like the rest-swagger component
> > https://camel.apache.org/components/latest/rest-swagger-component.html
> >
> > However this is for Camel to call an existing REST service by
> > referring to the swagger api of the service.
> >
> > On Fri, Nov 8, 2019 at 10:17 PM Ron Cecchini <[hidden email]> wrote:
> > >
> > > I'm taking a shot here...
> > >
> > > I'm new to Swagger.
> > >
> > > I see that Camel has integration for generating Swagger APIs.
> > >
> > > But what about *reading* someone else's API and using their schemas in my routes?
> > >
> > > I'm looking at Swagger Codegen to see how to generate the client code...  But given Camel's infinite awesomeness, I was wondering if Camel or anyone has basically automated the process so that, say, at start up you can dynamically grab someone's API and use that to parse data from their endpoints, etc.
> > >
> > > Thanks and have a great weekend everyone.
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Camel and Swagger API *client* code

Ron Cecchini

Thanks again, Claus.  Your tireless promotion of Camel and efforts to help us Camel Riders everywhere is deeply appreciated.  I don't think I've yet googled a Camel question where you weren't in the responses.  I don't know how you find the time or energy to answer as many questions as you.  I swear you must have a doppelganger!  (If I take the kids to the zoo next year and you're at the camel exhibit then I'll know something truly WEIRD is going on...)

Actually, I deeply appreciate the entire greater Camel community.  It's a great community.  And it's a great technology you've created.  I feel like I can build a career (well, I have a career... but integration & pipelining is so fun) or a company built on Camel and Spring Boot, and using just your fantastic book - which covers everything.

Anyway, I will probably take you up on your offer to discuss more things -- but first I need to study chapter 13 on Parallel Processing so I don't ask any stupid questions...  (The teaser is that it regards the pipeline I'm working on and about how to use Camel's parallel processing most effectively.  In particular, if I have an Ingest that receives a 1000 item JSON array every few seconds, is there a performance impact if I split() the array first and feed each item to the rest of the processing/body pipeline; versus having Ingest pass the JSON array intact, and let the processing body do the split() and .paralleProcessing().  I guess really the question is: if a route is receiving items one at a time, can you even do any kind of parallelization at that point; i.e. does the parallelization depend on being colocated with the split()?  Ok, I'm asking the stupid questions I said I wouldn't ask yet...  Sorry.)

Thank you again.

Ron

> On November 11, 2019 at 1:38 PM Claus Ibsen <[hidden email]> wrote:
>
>
> Hi Ron
>
> Good to hear that you can find a solution, and thats its a step up
> with your Camel adventure.
>
> The community is here if you need help or want to discuss something.
> And then mind Camel 3 is around the corner so that brings you new
> adventures too ;)
>
>
> On Sat, Nov 9, 2019 at 7:37 AM Ron Cecchini <[hidden email]> wrote:
> >
> > Hi, Claus.  Thanks for your response.
> >
> > The Camel "rest-swagger" looks awesome but unfortunately I don't think I can use it, because what I actually need are the data models created from the Swagger OpenAPI specs.
> >
> > And as it turns out, Maven's "swagger-codegen-maven-plugin" is precisely what I need.  I misspoke earlier when I said I wanted to dynamically pull in the API at startup.  I was just trying to avoid a manual CodeGen ("swagger-codegen-cli") step before compiling.
> >
> > But with the Maven plugin I can grab the API and generate the models at compile time - which is perfectly suitable for my needs.  And it's great that the plugin lets you specify either a URL or a local JSON file (which is what I'll end up using), and it lets you generate exactly the models you need (instead of all of them).
> >
> > I'm sure this is all old hat to you guys, but I'm new to it...
> >
> > Thank you again.
> >
> > Ron
> >
> > ...
> >
> > FWIW: I got my tech lead excited about Camel and Spring Boot and he gave me the go ahead.  I'm creating a Spring Boot + Camel pipeline with a scalable Ingest "head" where multiple rest components will each hit a different endpoint to get a JSON array of hundreds or thousands of elements.  I'll then use Camel to split the array, start some Camel parallelProcessing() or threads() or whatever, convert each JSON to one of the model POJOs created by Swagger, then convert each model to a custom model, and write it to a Kafka topic to feed the rest of the pipeline.  (or maybe it's better for Ingest to just write the JSON elements to Kafka, and let the other side of the pipeline do the JSON transforming...)  Anyway, should be pretty neat, and it'll be much less code than what they currently have.  It's pretty straight forward stuff you guys do all the time, but it'll be my biggest Camel implementation yet, and I'm glad I'm getting to showcase Camel as being something other than a tool to
  jus

> >  t "read from a JMS and write to a JMS".
> >
> > > On November 8, 2019 at 4:24 PM Claus Ibsen <[hidden email]> wrote:
> > >
> > >
> > > Hi
> > >
> > > Maybe something like the rest-swagger component
> > > https://camel.apache.org/components/latest/rest-swagger-component.html
> > >
> > > However this is for Camel to call an existing REST service by
> > > referring to the swagger api of the service.
> > >
> > > On Fri, Nov 8, 2019 at 10:17 PM Ron Cecchini <[hidden email]> wrote:
> > > >
> > > > I'm taking a shot here...
> > > >
> > > > I'm new to Swagger.
> > > >
> > > > I see that Camel has integration for generating Swagger APIs.
> > > >
> > > > But what about *reading* someone else's API and using their schemas in my routes?
> > > >
> > > > I'm looking at Swagger Codegen to see how to generate the client code...  But given Camel's infinite awesomeness, I was wondering if Camel or anyone has basically automated the process so that, say, at start up you can dynamically grab someone's API and use that to parse data from their endpoints, etc.
> > > >
> > > > Thanks and have a great weekend everyone.
> > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > http://davsclaus.com @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2