-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scala] added new scala-cask generator for the cask framework #18046
Conversation
.gitignore
Outdated
@@ -282,3 +282,4 @@ samples/openapi3/client/petstore/go/privatekey.pem | |||
|
|||
## OCaml | |||
samples/client/petstore/ocaml/_build/ | |||
samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Why add this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - I think that's a hang over from what I was using as an output directory. I'll remove it. Thanks
.run/CaskCodeGen.run.xml
Outdated
<option name="Make" enabled="true" /> | ||
</method> | ||
</configuration> | ||
</component> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a run profile for testing -- something I can just take out
thanks for the PR. can you please also add the new sample folder to .github/workflows/samples-scala.yaml so that the CI can test it moving forward? |
please ping me via Slack if you need help with this PR. https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g thanks again for the PR |
I think I've addressed the comments in the PR - many thanks @wing328 for the review! |
How very exciting! Thanks all for your time and patience in reviewing -- very much appreciated! |
Thanks @wing328 for the review and help. I've just updated the branch and included server validation improvements, so hopefully is ready for another review? |
can you please take a look at the CI build failure when you've time? let me know if you need help to fix it. |
the scala cask tests also failed: https://github.com/OpenAPITools/openapi-generator/actions/runs/8440910764/job/23134573837?pr=18046 please take a look when you've time |
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
the test failed. can you please take a look? |
Thanks William -
Looks like I’ve got some work to do!
Thanks so much for the helpful comments 👍
…On Sat, 30 Mar 2024 at 13:27, William Cheng ***@***.***> wrote:
the test failed. can you please take a look?
https://github.com/OpenAPITools/openapi-generator/actions/runs/8468026875/job/23262734520?pr=18046
—
Reply to this email directly, view it on GitHub
<#18046 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABMIOKYFZNRMO3SLDDLMU3Y224VZAVCNFSM6AAAAABEJ32LSOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYGA2TQNJTGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
So, for the first failure
<https://github.com/OpenAPITools/openapi-generator/actions/runs/8440910756/job/23134572125?pr=18046>,
I have no idea what this is / where it comes from / if it's from my PR:
java.lang.IllegalArgumentException: Null key for a Map not allowed in JSON
(use a converting NullKeySerializer?) (through reference chain:
java.util.LinkedHashMap["components"]->java.util.LinkedHashMap["schemas"]->java.util.LinkedHashMap["Good"]->java.util.LinkedHashMap["properties"]->java.util.LinkedHashMap["null"])
It seems to be innocuous / doesn't affect things now, though I can
reproduce that / see that failure locally.
I've added my ***@***.***' as a secondary email to my Github
account -- thanks for that!
It looks like a lot of these failures
<https://github.com/OpenAPITools/openapi-generator/actions/runs/8468026875/job/23262734520?pr=18046>
are for other scala projects (lagom, scalaz, finch). I'll double-check, but
I can't see how my PR is affecting these other projects?
[image: image.png]
For the cask one I've introduced
<https://github.com/OpenAPITools/openapi-generator/actions/runs/8468026875/job/23262735057?pr=18046#step:5:40>,
I can't reproduce that locally. I've run the steps:
./mvnw clean package
./bin/generate-samples.sh ./bin/configs/*.yaml
co
At this point I've checked the code generated
in /samples/server/petstore/scala/cask and it all builds ok for me /
compiles and tests just fine?
I should note, the compile step does reformat the code, so I'm not sure if
that has an impact/makes a difference?
I regularly sink my fork and rebuild.
I'll double-check my changes if they can affect the other scala projects,
but not quite sure where else to go from here.
As ever, thanks so much for your time and help!
Best,
Aaron
On Sat, Mar 30, 2024 at 1:36 PM Aaron Pritzlaff ***@***.***>
wrote:
… Thanks William -
Looks like I’ve got some work to do!
Thanks so much for the helpful comments 👍
On Sat, 30 Mar 2024 at 13:27, William Cheng ***@***.***>
wrote:
> the test failed. can you please take a look?
>
>
> https://github.com/OpenAPITools/openapi-generator/actions/runs/8468026875/job/23262734520?pr=18046
>
> —
> Reply to this email directly, view it on GitHub
> <#18046 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABMIOKYFZNRMO3SLDDLMU3Y224VZAVCNFSM6AAAAABEJ32LSOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYGA2TQNJTGY>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
can you review and fix: https://github.com/OpenAPITools/openapi-generator/actions/runs/8492216876/job/23265283400?pr=18046? for test failures with other scala samles, please ignore those for the time being |
public OperationGroup(String httpMethod, String pathPrefix) { | ||
this.httpMethod = httpMethod; | ||
this.pathPrefix = pathPrefix; | ||
caskAnnotation = "@cask." + httpMethod.toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for toLowerCase, you will need to use Locale.ROOT to address the build failure:
Line 125 in 1704ae1
additionalProperties.put("httpClientGprName", httpClientPackageName.toLowerCase(Locale.ROOT)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boom! Smashing through these. Fixed - thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please also fix the rest?
Forbidden method invocation: java.lang.String#toUpperCase() [Uses default locale]
Error: in org.openapitools.codegen.languages.ScalaCaskServerCodegen (ScalaCaskServerCodegen.java:376)
Error: Forbidden method invocation: java.lang.String#toUpperCase() [Uses default locale]
Error: in org.openapitools.codegen.languages.ScalaCaskServerCodegen (ScalaCaskServerCodegen.java:37[9](https://github.com/OpenAPITools/openapi-generator/actions/runs/8505836811/job/23295001534?pr=18046#step:5:10))
Error: Scanned 529 class file(s) for forbidden API invocations (in 1.00s), 2 error(s).
Error: Failed to execute goal de.thetaphi:forbiddenapis:3.5.1:check (default) on project openapi-generator: Check for forbidden API calls failed, see log. -> [Help 1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yepper - done
can you please take a look at https://github.com/OpenAPITools/openapi-generator/actions/runs/8505982227/job/23295571166?pr=18046 ? |
samples seems not up-to-date: https://github.com/OpenAPITools/openapi-generator/actions/runs/8505982218/job/23295650385?pr=18046 please regenerate the samples |
array = pathPrefix.split(File.separator, -1); | ||
} catch (PatternSyntaxException exp) { | ||
throw new RuntimeException("For some reason, splitting >" + pathPrefix + "< on >" + File.separator + "< threw " + exp, exp); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this line is throwing exception in windows?
what about using just /
instead of File.separator, which is \
in windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch - done
protected String gitUserId = env("GIT_USER", System.getProperty("user.name")); | ||
protected String gitRepoId = env("GIT_REPO", artifactId); | ||
protected String appName = env("APP_NAME", "Cask App"); | ||
protected String infoEmail = env("INFO_EMAIL", "[email protected]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for gitUserId and gitRepoId, you can use these directly from default codegen.
please do not use environment variables, and use additional properties instead. e.g. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaHttpServerCodegen.java#L174-L224
infoEmail should be obtained from the spec so I don't think we need to set it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks.
I've reworked these properties and cleaned up a lot of the debug code.
I've changed the sample properties and output destination -- I hope that's not too confusing to follow from the original PR
@wing328, it looks like this might be good to go, unless I've missed something? |
.github/workflows/samples-scala.yaml
Outdated
@@ -32,6 +32,7 @@ jobs: | |||
- samples/server/petstore/scalatra | |||
- samples/server/petstore/scala-finch # cannot be tested with jdk11 | |||
- samples/server/petstore/scala-http4s-server | |||
- samples/server/petstore/scala/cask |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be samples/server/petstore/scala-cask
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - good catch. updated
@@ -0,0 +1,53 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "mo/del" folder looks a bit weird to me.
should it be simply just "model"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just testing out weird/nested configs, but you're right. I've updated it now to be a more standard package structure
…which have been reformatted
Removed cask client samples
i've filed #18344 based on this PR with some minor enhancements. |
merged #18344 (commits still authored by you). thanks for the new generator 👍 |
This change adds a new scala-cask generator for the cask framework.
Thanks in advance to scala committee reviewers @clasnake, @jimschubert, @shijinkui, @ramzimaalej, @chameleon82, @Bouillie and/or @Fish86
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)