indiscriminatecoding / api4s

Derive Scala code for your HTTP API from swagger!

Version Matrix

api4s - HTTP API in Scala


Document your HTTP API with swagger and generate Scala code from it.

Uses http4s and circe for autogenerated code.


The simplest way to use this library is via sbt plugin. Add following line to project/plugins.sbt:

addSbtPlugin("com.github.IndiscriminateCoding" % "api4s-sbt" % "0.2.6")

Also you need to enable plugin usage in build.sbt:

lazy val root = (project in file("."))
    libraryDependencies += "com.github.IndiscriminateCoding" %% "api4s-core" % "0.2.6",
    api4sSources := Seq(Api4s.Src(
      file = sourceDirectory.value / "main" / "swagger" / "my-specification.yaml",
      pkg = "com.example",
      server = true,
      client = true

At this point you can just compile your project and see what is generated by plugin.

Detailed example is here.


  • No OpenAPI 3.0 support at this moment; only swagger is supported
  • Specifications in JSON format isn't supported; use YAML instead