[LagomScala] Add Scala API generator for lagomframework #6900#6901
[LagomScala] Add Scala API generator for lagomframework #6900#6901wing328 merged 7 commits intoswagger-api:masterfrom
Conversation
| import java.io.File; | ||
| import java.util.*; | ||
|
|
||
| public abstract class AbstractScalaLagomCodegen extends DefaultCodegen { |
There was a problem hiding this comment.
@gmkumar2005 Instead of creating another abstract class, what about using AbstractScalaCodegen.java instead?
|
|
||
| import java.util.*; | ||
|
|
||
| public class LagomScalaApiCodegen extends AbstractScalaLagomCodegen implements CodegenConfig { |
There was a problem hiding this comment.
I would suggest naming it as "ScalaLagomServerCodegen" following the naming convention of other server generator.
|
|
||
| @Override | ||
| public CodegenType getTag() { | ||
| return CodegenType.CLIENT; |
There was a problem hiding this comment.
Please use CodegenType.SERVER instead.
|
|
||
| @Override | ||
| public String getName() { | ||
| return "lagomScalaApi"; |
There was a problem hiding this comment.
I would suggest scala-lagom to follow the naming convention "{language}-{lagom}"
There was a problem hiding this comment.
Changed to scala-lagomApi to be able to distinguish from impl.
There was a problem hiding this comment.
I don't understand that part about distinguish from impl, can you clarify?
| io.swagger.codegen.languages.TypeScriptNodeClientCodegen | ||
| io.swagger.codegen.languages.UndertowCodegen | ||
| io.swagger.codegen.languages.ZendExpressivePathHandlerServerCodegen | ||
| io.swagger.codegen.languages.LagomScalaApiCodegen No newline at end of file |
There was a problem hiding this comment.
Better to put it according to alpabetical order
| @@ -0,0 +1,10 @@ | |||
| // | |||
| // Copyright (C) 2016 Lightbend Inc. <https://www.lightbend.com> | |||
There was a problem hiding this comment.
Can we remove it? The autogenerated files are unlicensed by default.
|
We can have another PR later to improve the code format. Ref: Scala style guide - http://docs.scala-lang.org/style/ |
|
|
||
| @Override | ||
| public String getHelp() { | ||
| return "Generates a Lagom API in scala"; |
There was a problem hiding this comment.
FYI. I'll add the word "beta" later to help manage user expectation similar to what we've done for other new generators.
…ved licensing info from generated code
jimschubert
left a comment
There was a problem hiding this comment.
I won't have time to evaluate in depth for a few days.
At first glance, I only had one comment.
Although, I'm not familiar with Lagom… and the method signatures missing input parameters was weird to me. I'll have to run locally and see if the structure is just how Lagom does things. When I looked at it (I think pre-1.0 when it was only Java), it had a lot of abstractions even in Java.
| public String toVarName(String name) { | ||
| // sanitize name | ||
| name = sanitizeName( | ||
| name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. |
There was a problem hiding this comment.
This looks like a copy/paste. Can it be updated/fixed here, or does that affect something elsewhere?
String modifiedName = name;
Then, use modifiedName within the method?
There was a problem hiding this comment.
Jim, you are right it is a copy paste from ScalaClientCodegen.Java. I guess this is needed for scala variables. Not sure what will break. Hence retained the logic.
With reference to method signatures.
Please have a look at https://github.com/lagom/sbt-lagom-descriptor-generator
The method signature generated by this PR matches with the one generated in above project.
Please let me know if you find any gaps.
|
I ran |
|
UPDATE: I did another test and no longer encountered those errors. |
|
|
||
| @Override | ||
| public String getName() { | ||
| return "scala-lagomApi"; |
There was a problem hiding this comment.
I'll change this to scala-lagom to conform to our naming convention.
|
|
||
| @Override | ||
| public String getHelp() { | ||
| return "Generates a Lagom API in scala"; |
There was a problem hiding this comment.
I'll add the word "beta" to the description.
|
@gmkumar2005 I've merged #7011 (enhancements, etc) into master. Please pull the latest master and let me know if you've any question. |
|
@wing328 lagom is a framework that supports generating both servers and clients. I see in that PR that you changed the generator to |
|
@jimschubert sure. I'll rename it to |
|
@jimschubert done via #7014 |
|
@gmkumar2005 when you've time, please reach me at my email address listed on my Github profile. Thanks. |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.2.3.0branch for changes related to OpenAPI spec 3.0. Default:master.Description of the PR
This change will support code generation of Lagom Scala API. Lagom Scala Api project can be used for writing an implementation or as a client to consume an external service.
####Features which are not supported