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.