This plugin use OpenApi-Generator(ex Swagger) to generate Models and Controllers for REST services
Step 1: create project/sbt-openapi-generator.sbt
with:
resolvers += Resolver.bintrayIvyRepo("adenza", "sbt-plugins")
addSbtPlugin("com.github.adenza" % "sbt-openapi-generator" % "0.2.0")
Most configuration settings is similar to CLI commands
Base configuration is based on project module as recommended way to separate generations by modules.
With the next example module generated
will be defined
lazy val generated = project.in(file("generated"))
.settings(
inConfig(OpenApiCodegen) {
Seq(
inputSpec := "openapi.yaml",
configFile := "config.yaml",
// outputPath := (baseDirectory in ThisBuild).value + "/generated"
)
}
)
Settings will be picked up from configFile
first if defined and then overwritten with module specified settings
There is an auto helpers to redifine boolean settings to make settings more readable:
validateSpec := SettingDisabled,
generateModelTests := SettingEnabled,
To print list of available languages use
sbt openApiGenerators
To run generation process
sbt openApiGenerate
or per module
sbt generated/openApiGenerate
Write plugin integration tests under /src/sbt-test
To run tests execute
sbt scripted