A single point of truth
Describe the shape of an API once. Guardrail constrains HTTP to the terms of your service so routing, validation, and clients stay aligned.
OpenAPI · Scala · Java
Read an OpenAPI specification. Generate type-safe servers and clients. When the contract changes, the compiler tells you — before production does.
petstore.yaml · OpenAPI 3
1openapi: "3.0.3"2info:3 title: Petstore4paths:5 /pets/{id}:6 get:7 operationId: getPet8 parameters:9 - name: id10 in: path11 required: true12 responses:13 "200":14 # User · Pet15 schema:16 $ref: "#/components/schemas/Pet"
Agent · http4s · Scala 3
1trait PetsHandler[F[_]]:2 def getPet(3 id: Long4 ): F[GetPetResponse]56sealed abstract class GetPetResponse7object GetPetResponse:8 case class Ok(value: Pet)9 case object NotFound1011// spec change → compile error12def getPet(id: Long, tenant: String)13 ^ missing override
Why teams generate
Describe the shape of an API once. Guardrail constrains HTTP to the terms of your service so routing, validation, and clients stay aligned.
New or changed parameters become unimplemented members. Optional fields surface as Option. Forgotten responses cannot be returned.
Generated clients skip the bespoke HTTP stack that usually ships with a hand-written SDK. You keep your client, retries, and versions.
In every build, at every step
Guardrail runs where your sources already compile. Generated files land in managed source directories and are overwritten on every build — so the spec stays authoritative.
// project/plugins.sbt
addSbtPlugin("dev.guardrail" % "sbt-guardrail" % latest)
// build.sbt
Compile / guardrailTasks := List(
ScalaClient(file("github.yaml"), framework="http4s"),
)
http4s
Scala
Circe codecs, routes, and clients
akka-http
Scala
Directives and marshallers
dropwizard
Scala & Java
Resources and Jackson
spring-mvc
Java
Controllers with Jackson
“Incomplete specifications, slippage between spec and implementation, extra semantics of infrastructure — these are the problems Guardrail is built to collapse.”
“Once specified, unused warnings point out that we’ve forgotten to reflect the latest change in our tests. A win on both fronts.”
“Providing an implementation of a function with a well-defined set of inputs and outputs is natural. Reduce the interface; the business logic gets clearer.”
Adopted in production at Twilio and Avast.
Start with sbt, Maven, Gradle, or the CLI. If you need help migrating a service, write hello@guardrail.dev.