Skip to content
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

Not generating anything but output success #31

Open
JFCote opened this issue Feb 9, 2021 · 5 comments
Open

Not generating anything but output success #31

JFCote opened this issue Feb 9, 2021 · 5 comments

Comments

@JFCote
Copy link
Member

JFCote commented Feb 9, 2021

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.

C:\dev\CS\CSBackEnd>sbt 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/)
[success] Total time: 0 s, completed Feb 9, 2021 9:05:55 AM

I followed the example pretty closely.

Here is my config.yml

generatorName: "java-play-framework"
outputDir : "generated"
additionalProperties:
  hideGenerationTimestamp: "true"
  booleanGetterPrefix: "is"

Here is the new part of the build.sbt

lazy val generated = project.in(file("generated"))
  .settings(
    openApiInputSpec := "swagger.yaml",
    openApiConfigFile := "config.yml",
    openApiValidateSpec := SettingEnabled,
    openApiGenerateModelTests := SettingDisabled
  )

All the files are at the root, there is only one module in my project... Am I missing something important?
Thanks

@JFCote JFCote changed the title Not generating anything but success Not generating anything but output success Feb 9, 2021
@jrouly
Copy link
Contributor

jrouly commented Feb 12, 2021

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

@JFCote
Copy link
Member Author

JFCote commented Feb 12, 2021

@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.

image

I'm going to try with your sample project later today but here are couple of difference I can see:

  • My yml spec is using OpenAPI v2 instead of v3
  • My spec is very large, spawning across multiple files.

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.

@JFCote
Copy link
Member Author

JFCote commented Feb 12, 2021

@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.

@jrouly
Copy link
Contributor

jrouly commented Feb 12, 2021

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

@jrouly
Copy link
Contributor

jrouly commented Feb 16, 2021

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants