Tests = Documentation
Your routing tests define paths, methods, parameters, security, and response examples. Baklava captures all of this and generates documentation automatically. No separate spec files to maintain.
Multiple Output Formats
Generate OpenAPI 3.0 specs (with optional SwaggerUI), browsable HTML pages, or TypeScript contracts with ts-rest and Zod schemas. Add any format by adding a dependency — auto-discovered, zero config.
Works With Your Stack
Pekko HTTP or http4s. ScalaTest, Specs2, or MUnit. Scala 2.13 or 3. Mix and match — Baklava adapts to your project, not the other way around.
Write tests, get docs
The Baklava DSL is a thin layer on top of your existing test framework. Define your API structure, write assertions, run sbt test — documentation appears in target/baklava/.
// project/plugins.sbt
addSbtPlugin("pl.iterators" % "baklava-sbt-plugin" % "1.1.1")
// build.sbt
libraryDependencies ++= Seq(
"pl.iterators" %% "baklava-pekko-http" % "1.1.1" % Test,
"pl.iterators" %% "baklava-scalatest" % "1.1.1" % Test,
"pl.iterators" %% "baklava-openapi" % "1.1.1" % Test,
)
path("/users/{userId}")(
supports(
GET,
pathParameters = p[Long]("userId"),
summary = "Get user by ID",
tags = Seq("Users")
)(
onRequest(pathParameters = 1L)
.respondsWith[User](OK, description = "User found")
.assert { ctx =>
val response = ctx.performRequest(routes)
response.body.name shouldBe "Alice"
},
onRequest(pathParameters = 999L)
.respondsWith[ErrorResponse](NotFound, description = "User not found")
.assert { ctx => ctx.performRequest(routes) }
)
)