Created by: cchafer
When the official OpenAPITools / sbt-openapi-generator sbt plugin is used to generate a scala-akka-http-server stub, the resulting files are a project in their own right, including:
- a build file
- a README.md file
- a default controller (controller.scala)
The problem is that it can be interesting not to generate a project, but just the source files needed to compile a project. By generating just scala files, which are placed in the managedSources of sbt, one can automate the generation of models and APIs within a project, without having to filter unnecessary files that prevent compilation.
This is what this modification allows. By adding the asManagedSources parameter in the additional properties of the generator, the build.sbt, README.md and controller.scala files will be ignored.
It is then possible, in the build file of the project, to simply define sbt-openapi-generator as a source generator:
openApiAdditionalProperties := Map("asManagedSources" -> "true")
Compile / sourceGenerators += openApiGenerate
By doing that, not a single manual operation is needed when openapi specification changes. Just by recompiling the project, the developer will see the templates and APIs updated and compiled at the same time.
Btw, syntax is far from perfect, due to the usage of a string to express the Boolean, but this is all due to sbt-openapi-generator...