You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Roman Shaposhnik <ro...@shaposhnik.org> on 2016/12/23 22:29:08 UTC

Groovy and Swagger

Hi!

I was wondering if there are any bindings available
for Groovy when it comes to creating REST APIs
with Swagger.

Any thoughts?

Thanks,
Roman.

Re: Groovy and Swagger

Posted by Clark Richey <cl...@factgem.com>.
I'm not a big fan of auto generated code. I use annotation on my Groovy spring rest controllers to generate swagger docs. 

Sent from my iPhone

> On Dec 27, 2016, at 19:22, Roman Shaposhnik <ro...@shaposhnik.org> wrote:
> 
> Hi!
> 
>> On Fri, Dec 23, 2016 at 7:49 PM, Clark Richey <cl...@factgem.com> wrote:
>> I have very successfully used spring test controllers with swagger. This
>> article explains the dependencies.
>> http://www.3pillarglobal.com/insights/restful-api-documentation-using-swagger-and-spring-mvc
> 
> Perhaps I should've elaborated in my original question ;-)
> 
> At the end of the day Swagger is nothing but a static definition for REST
> APIs (now also known as OpenAPI https://www.openapis.org/). These definition
> can be either YAML or JSON and they are orthogonal to an API implementation.
> 
> Next come the tools that allow one to generate server-side scaffolding
> and client-side
> libraries. In fact, you can actually use a WebEditor to do that. Try
> it on an echo example
> (via File->Open Example in the top left): http://editor.swagger.io/#/
> 
> Once you open up that example YAML you can click on Generate Server and Generate
> Client menus in the same top bar. This is where things get interesting.
> 
> If you click on General Client and pick Groovy you'll basically get an
> auto-generated thin
> wrapper around HTTPBuilder. This is my first question -- is this the
> best client Groovy
> code that can be generated from a Swagger description or are there any
> other generators
> I may not know about.
> 
> The Generate Server is more interesting since you don't get Groovy as
> a choice, but you
> do get Spring, JAX-RS and Scalatra as choices. This is my 2nd
> question: for somebody
> who's interested in quick prototyping of a REST backend based on
> Swagger definition
> what would be a recommendation here? Personally, I'd rather have
> something like Boot
> and/or Dropwizard, or anything that's Groovy (I'm not a Web guy --
> hence asking).
> 
> Now, treating Java/Groovy source as a source of truth instead of the
> YAML brings us
> to my 3d question that you actually answered somewhat: is there any
> way to generate
> Groovy REST client  based on the Spring annotations that are sprinkled
> on top of source
> in your example (I'd assume one way to do it would be to ask for
> Swagger YAML/JSON
> to be generated based on those annotations -- but I'll keep my options
> open ;-)).
> 
> Thanks,
> Roman.

Re: Groovy and Swagger

Posted by Roman Shaposhnik <ro...@shaposhnik.org>.
Hi!

On Fri, Dec 23, 2016 at 7:49 PM, Clark Richey <cl...@factgem.com> wrote:
> I have very successfully used spring test controllers with swagger. This
> article explains the dependencies.
> http://www.3pillarglobal.com/insights/restful-api-documentation-using-swagger-and-spring-mvc

Perhaps I should've elaborated in my original question ;-)

At the end of the day Swagger is nothing but a static definition for REST
APIs (now also known as OpenAPI https://www.openapis.org/). These definition
can be either YAML or JSON and they are orthogonal to an API implementation.

Next come the tools that allow one to generate server-side scaffolding
and client-side
libraries. In fact, you can actually use a WebEditor to do that. Try
it on an echo example
(via File->Open Example in the top left): http://editor.swagger.io/#/

Once you open up that example YAML you can click on Generate Server and Generate
Client menus in the same top bar. This is where things get interesting.

If you click on General Client and pick Groovy you'll basically get an
auto-generated thin
wrapper around HTTPBuilder. This is my first question -- is this the
best client Groovy
code that can be generated from a Swagger description or are there any
other generators
I may not know about.

The Generate Server is more interesting since you don't get Groovy as
a choice, but you
do get Spring, JAX-RS and Scalatra as choices. This is my 2nd
question: for somebody
who's interested in quick prototyping of a REST backend based on
Swagger definition
what would be a recommendation here? Personally, I'd rather have
something like Boot
and/or Dropwizard, or anything that's Groovy (I'm not a Web guy --
hence asking).

Now, treating Java/Groovy source as a source of truth instead of the
YAML brings us
to my 3d question that you actually answered somewhat: is there any
way to generate
Groovy REST client  based on the Spring annotations that are sprinkled
on top of source
in your example (I'd assume one way to do it would be to ask for
Swagger YAML/JSON
to be generated based on those annotations -- but I'll keep my options
open ;-)).

Thanks,
Roman.

Re: Groovy and Swagger

Posted by Clark Richey <cl...@factgem.com>.
I have very successfully used spring test controllers with swagger. This article explains the dependencies. http://www.3pillarglobal.com/insights/restful-api-documentation-using-swagger-and-spring-mvc

Sent from my iPhone

On Dec 23, 2016, at 19:54, Paul King <pa...@asert.com.au>> wrote:

Interesting idea! I haven't used Swagger myself though, so I'm
possibly not the best to comment.

Cheers, Paul.


On Sat, Dec 24, 2016 at 8:29 AM, Roman Shaposhnik <ro...@shaposhnik.org>> wrote:
Hi!

I was wondering if there are any bindings available
for Groovy when it comes to creating REST APIs
with Swagger.

Any thoughts?

Thanks,
Roman.

Re: Groovy and Swagger

Posted by Paul King <pa...@asert.com.au>.
Interesting idea! I haven't used Swagger myself though, so I'm
possibly not the best to comment.

Cheers, Paul.


On Sat, Dec 24, 2016 at 8:29 AM, Roman Shaposhnik <ro...@shaposhnik.org> wrote:
> Hi!
>
> I was wondering if there are any bindings available
> for Groovy when it comes to creating REST APIs
> with Swagger.
>
> Any thoughts?
>
> Thanks,
> Roman.