Open JFCote opened 3 years ago
Hey @JFCote! I tried out the snippets you pasted over here. I ran $ sbt openApiGenerate
on Linux and then checked in the resulting generated
folder. Can you do a quick check of that build definition against yours?
Can you also try running $ sbt 'show openApiGenerate'
to print the list of generated files after generation, if any? The output looks something like this for me:
$ sbt 'show openApiGenerate'
[info] welcome to sbt 1.3.13 (Oracle Corporation Java 1.8.0_265)
[info] loading settings for project global-plugins from plugins.sbt ...
[info] loading global plugins from /home/jrouly/.sbt/1.0/plugins
[info] loading settings for project sbt-openapi-generator-build from plugins.sbt ...
[info] loading project definition from /home/jrouly/stuff/code/sbt-openapi-generator/project
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] loading settings for project sbt-openapi-generator from build.sbt ...
[info] set current project to sbt-openapi-generator (in build file:/home/jrouly/stuff/code/sbt-openapi-generator/)
[info] read configuration from config.yml
[info] Successfully generated code to generated
[info] generated / openApiGenerate
[info] Buffer(generated/app/apimodels/Category.java, generated/app/apimodels/InlineObject.java, generated/app/apimodels/InlineObject1.java, generated/app/apimodels/ModelApiResponse.java, generated/app/apimodels/Order.java, generated/app/apimodels/Pet.java, generated/app/apimodels/Tag.java, generated/app/apimodels/User.java, generated/app/controllers/PetApiController.java, generated/app/controllers/PetApiControllerImpInterface.java, generated/app/controllers/PetApiControllerImp.java, generated/app/controllers/StoreApiController.java, generated/app/controllers/StoreApiControllerImpInterface.java, generated/app/controllers/StoreApiControllerImp.java, generated/app/controllers/UserApiController.java, generated/app/controllers/UserApiControllerImpInterface.java, generated/app/controllers/UserApiControllerImp.java, generated/README, generated/LICENSE, generated/build.sbt, generated/project/build.properties, generated/project/plugins.sbt, generated/conf/logback.xml, generated/conf/application.conf, generated/conf/routes, generated/app/Module.java, generated/app/openapitools/OpenAPIUtils.java, generated/app/openapitools/ErrorHandler.java, generated/app/openapitools/ApiCall.java, generated/public/openapi.json, generated/app/controllers/ApiDocController.java, /home/jrouly/stuff/code/sbt-openapi-generator/generated/.openapi-generator-ignore, generated/.openapi-generator/VERSION)
[info] openApiGenerate
[info] List()
[success] Total time: 2 s, completed Feb 11, 2021 9:35:41 PM
@jrouly First. I must add that I'm using Windows 10 in case it might be related (even if sbt is cross platform).
Here is the result with the command sbt "show openApiGenerate"
. It seems to add a *
in the output but I can't find any generated code.
C:\dev\CS\CSBackEnd>sbt "show openApiGenerate"
[info] welcome to sbt 1.3.13 (Oracle Corporation Java 1.8.0_201)
[info] loading global plugins from C:\Users\jcote\.sbt\1.0\plugins
[info] loading settings for project csbackend-build from plugins.sbt ...
[info] loading project definition from C:\dev\CS\CSBackEnd\project
[info] loading settings for project root from build.sbt ...
[info] set current project to S360ControlSite (in build file:/C:/dev/CS/CSBackEnd/)
[info] *
[success] Total time: 0 s, completed Feb 12, 2021 6:53:33 AM
The generated folder only contains a target
folder without code.
I'm going to try with your sample project later today but here are couple of difference I can see:
If you are on the openapi-generator slack , I could send you the files and you could test it on your side? I will try to reach you today on Slack.
@jrouly I have tried with your project in branch issue.31
and it worked. Then, I replaced your spec with mine and received this strange error. Maybe this type of log is turned off in my own project?
C:\dev\Tools\sbt-openapi-generator>sbt "show openApiGenerate"
[info] welcome to sbt 1.3.13 (Oracle Corporation Java 1.8.0_201)
[info] loading global plugins from C:\Users\jcote\.sbt\1.0\plugins
[info] loading settings for project sbt-openapi-generator-build from plugins.sbt ...
[info] loading project definition from C:\dev\Tools\sbt-openapi-generator\project
C:\dev\Tools\sbt-openapi-generator\generated\build.sbt:5: error: not found: value PlayJava
lazy val root = (project in file(".")).enablePlugins(PlayJava)
^
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? i
[warn] Ignoring load failure: no project loaded.
[error] Session not initialized.
[error] Use 'last' for the full log.
Let me know if you need more information.
We spoke on Slack, but summarizing here: I was able to generate code using the same sample build setup and your provided spec files, so the multi-file spec is not an issue.
When I run sbt "show openApiGenerate"
using your spec files, I see the following output (snippet):
$ sbt "show openApiGenerate"
[info] welcome to sbt 1.4.6 (AdoptOpenJDK Java 1.8.0_265)
[info] loading settings for project global-plugins from plugins.sbt ...
[info] loading global plugins from /Users/michel.rouly/.sbt/1.0/plugins
[info] loading settings for project jfcote-build from plugins.sbt ...
[info] loading project definition from /private/tmp/jfcote/project
[info] loading settings for project jfcote from build.sbt ...
[info] set current project to jfcote (in build file:/private/tmp/jfcote/)
[info] read configuration from config.yml
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################
[info] Successfully generated code to generated
[info] generated / openApiGenerate
[info] Buffer(generated/app/apimodels/ActionType.java, ... ) <--- this is a very long list of generated files
[info] openApiGenerate
[info] List()
[success] Total time: 31 s, completed Feb 12, 2021 9:37:34 AM
It's interesting that in your first provided output, after set current project
, there's no read configuration from config.yml
. This seems to indicate that the generator is not being invoked at all. I'm not entirely sure why the *
is present - normally this refers to the global configuration in sbt.
Even if I run something like sbt "show compile"
, I still see relevant output:
...
[info] set current project to jfcote (in build file:/private/tmp/jfcote/)
[info] generated / Compile / compile
[info] Analysis:
[info] Compile / compile
[info] Analysis:
[success] Total time: 1 s, completed Feb 12, 2021 9:40:06 AM
@JFCote Hm. The sample build works for me on Windows 10 as well:
C:\Users\jrouly\Code\sbt-openapi-generator>sbt openApiGenerate
[info] welcome to sbt 1.3.13 (AdoptOpenJDK Java 1.8.0_242)
[info] loading global plugins from C:\Users\jrouly\.sbt\1.0\plugins
[info] loading settings for project sbt-openapi-generator-build from plugins.sbt ...
[info] loading project definition from C:\Users\jrouly\Code\sbt-openapi-generator\project
[info] loading settings for project sbt-openapi-generator from build.sbt ...
[info] set current project to sbt-openapi-generator (in build file:/C:/Users/jrouly/Code/sbt-openapi-generator/)
[info] read configuration from config.yml
################################################################################
# Thanks for using OpenAPI Generator. #
# Please consider donation to help us maintain this project 🙏 #
# https://opencollective.com/openapi_generator/donate #
################################################################################
[info] Successfully generated code to generated
[success] Total time: 1 s, completed Feb 16, 2021 3:34:24 PM
There's definitely something about the rest of your build context that is causing the failure. Perhaps try deleting the other sbt projects and re-adding them one at a time?
Hi,
I'm trying to use
sbt-openapi-generator
but unfortunately, it doesn't seems to work.Here is the output in the command line. I receive a "success" but I can't find generated code anywhere. There is no error.
I followed the example pretty closely.
Here is my
config.yml
Here is the new part of the build.sbt
All the files are at the root, there is only one module in my project... Am I missing something important? Thanks