Tooling
Build plugins
Guardrail is meant to run inside the compile you already have. Plugins call the core and write managed sources on every build.
sbt
Install sbt-guardrail. Generated sources land in target/scala-2.12/src_managed/ and are overwritten on compile.
Compile / guardrailTasks := List(
ScalaClient(file("petstore.yaml")),
ScalaClient(file("github.yaml"), pkg = "com.example.clients.github"),
ScalaServer(file("myserver.yaml"), pkg = "com.example.server", tracing = true)
)
Test / guardrailTasks := List(
ScalaServer(file("petstore.yaml")),
ScalaServer(file("github.yaml"), pkg = "com.example.tests.github"),
ScalaClient(file("myserver.yaml"), pkg = "com.example.tests.server", tracing = true)
)Generating servers into test sources is useful for real mock downstream servers in unit tests.
Maven
Use guardrail-maven-plugin with generate-sources and a language / framework / kind configuration.
Gradle
The Gradle plugin is published on the Plugin Portal as dev.guardrail.
CLI
cs install guardrail installs the latest CLI via Coursier. The CLI supports the same backends as the plugins.