indiscriminatecoding / api4s   0.3.1

BSD 3-clause "New" or "Revised" License GitHub

Derive Scala code for your HTTP API from swagger!

Scala versions: 2.13 2.12
sbt plugins: 1.0

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" % latest)

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

lazy val root = (project in file("."))
    libraryDependencies += "com.github.IndiscriminateCoding" %% "api4s-core" % latest,
    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