guardrail

OpenAPI · Scala · Java

Guardrail is your coding agent for principled APIs.

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: Petstore
4paths:
5 /pets/{id}:
6 get:
7 operationId: getPet
8 parameters:
9 - name: id
10 in: path
11 required: true
12 responses:
13 "200":
14 # User · Pet
15 schema:
16 $ref: "#/components/schemas/Pet"

Agent · http4s · Scala 3

Generated handler
1trait PetsHandler[F[_]]:
2 def getPet(
3 id: Long
4 ): F[GetPetResponse]
5
6sealed abstract class GetPetResponse
7object GetPetResponse:
8 case class Ok(value: Pet)
9 case object NotFound
10
11// spec change → compile error
12def getPet(id: Long, tenant: String)
13 ^ missing override

Why teams generate

Specifications become compiler-checked code.

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.

Unexpected changes are compiler errors

New or changed parameters become unimplemented members. Optional fields surface as Option. Forgotten responses cannot be returned.

Fewer binary dependencies

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

Drop it into sbt, Maven, Gradle, or the CLI.

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"),

)

Targets that already live in production.

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

The new way to keep APIs honest.

“Incomplete specifications, slippage between spec and implementation, extra semantics of infrastructure — these are the problems Guardrail is built to collapse.”

Guardrail design notes

Single point of truth

“Once specified, unused warnings point out that we’ve forgotten to reflect the latest change in our tests. A win on both fronts.”

Compiler-checked APIs

Servers that cannot drift

“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.”

Separation of concerns

Handlers, not plumbing

Adopted in production at Twilio and Avast.

Generate the next change.

Start with sbt, Maven, Gradle, or the CLI. If you need help migrating a service, write hello@guardrail.dev.