groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roman Shaposhnik <>
Subject Re: Groovy and Swagger
Date Wed, 28 Dec 2016 00:22:01 GMT

On Fri, Dec 23, 2016 at 7:49 PM, Clark Richey <> wrote:
> I have very successfully used spring test controllers with swagger. This
> article explains the dependencies.

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 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):

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
to be generated based on those annotations -- but I'll keep my options
open ;-)).


View raw message