Swagger-codegen: Support play for java and scala server.

Created on 6 Jun 2016  Â·  10Comments  Â·  Source: swagger-api/swagger-codegen

Description

Seems no support for play now.
Shall we support play for java and scala server, so that server-side code based on the play framework can be auto-generated according to the rest spec.

Feature Java Scala help wanted

Most helpful comment

@clasnake : You'll be happy to know I've created a pull request for Java Play Framework: https://github.com/swagger-api/swagger-codegen/pull/4943
If it's merged, you will have all you need to generate a complete Java server with Play Framework.

All 10 comments

@clasnake we would definitely welcome contribution for a play framework server stub generator.

Here is a good starting point: https://github.com/swagger-api/swagger-codegen/wiki/How-to-add-a-generator-for-a-new-language-or-framework

@wing328 I'll take a look at this one. And shall we add label Server: Scala as well?

@wing328 Well I see the play integration at https://github.com/swagger-api/swagger-play as a separate repo and https://github.com/zalando/play-swagger to generate play code from the spec. So I guess no need to add it into swagger-codegen?

cc @ePaul

@wing328 Thanks for pinging me.

Although that project (zalando/play-swagger) is from my company, I didn't use it until now (my team is using neither Play nor Scala).

Looking at the README, it seems to have a bit different approach than Swagger-Codegen. It is integrated in the Scala Build tool, generating both managed code (i.e. code which is generated in the target folder, which you shouldn't edit) and unmanaged code (code which you can edit, and which might get modified later by the plugin, keeping your edits). I'm not sure if the latter one would be possible at all with Swagger-Codegen's current architecture.

(Swagger-Play seems to be the Scala/Play version corresponding to Java's Swagger-annotations, generating Swagger/OpenAPI from Play code. This would be the inverse approach to play-swagger, though both names should be swapped to describe what they are doing.)

@clasnake Please check if the play-swagger generator works for you (and report any issues back to that repository's tracker). If it doesn't, having more ways to support end-to-end type safety (which is one of the reasons I want to have Swagger-generation) is always good, so you are welcome to contribute a generator here (though I can't really comment much on it, knowing Scala only very superficially – I don't like the syntax).

Hi, is there something started for play framework codegen export? We would be interested in such feature and maybe we could contribute if something is already started. The alternative stated above are good but don't use the codegen and don't follow the process we would want to use. Let me know! Thanks

@JFCote there's a sample for Swagger Play framework sample app (Petstore) at https://github.com/swagger-api/swagger-play-sample-app (which was created 5 years ago)

One approach is to reverse engineer the output (the sample play app) back into the mustache template.

Let me know if you're interested in the work and we can work together to create the Play generator.

@wing328 : I'm VERY new to Swagger, I still need to understand a lots of thing before doing something like that. But right now I can tell you:

  • This sample is VERY old. Play Framework is now at version 2.5.10. So the first thing should be to update the sample to the latest version (or create a new one?).
  • Shoud we support multiple version of play or just the latest? (Each version have breaking changes)
  • Should we support Java and Scala codegen for Play? I know the Java part but don't have any experience is Scala.
  • What is a mustache template? :)

I need to learn a bit more about swagger, I'll keep you updated.

Shoud we support multiple version of play or just the latest? (Each version have breaking changes)

Let's start with the latest stable version (2.5.10) to being with.

Should we support Java and Scala codegen for Play? I know the Java part but don't have any experience is Scala.

Let's start with Java 😄

What is a mustache template? :)

An example is https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/Java/pojo.mustache#L79, which will be used by the Java generator when generating the models and {{...}} (e.g. {{name}}) are variables in the mustache template.

@clasnake : You'll be happy to know I've created a pull request for Java Play Framework: https://github.com/swagger-api/swagger-codegen/pull/4943
If it's merged, you will have all you need to generate a complete Java server with Play Framework.

Was this page helpful?
0 / 5 - 0 ratings