What is Tapir?
masterTapir is a library for describing HTTP APIs in a type-safe, declarative way. It allows you to define the shape of an endpoint (the "what") separately from its implementation (the "how"). Once an endpoint is defined, Tapir can automatically:
- Expose it as a server: Integrate with major Scala HTTP server implementations (Netty, Akka HTTP, Pekko HTTP, Http4s, etc.).
- Consume it as a client: Generate client requests using interpreters (like
sttp4). - Document it: Automatically generate documentation in OpenAPI, AsyncAPI, or JSON Schema formats.
Key benefits include compile-time type safety, high performance (via a Netty-based server), and seamless integration with the Scala ecosystem (JSON libraries like Circe, observability tools, and functional programming stacks).
endpoint
.get.in("hello").in(query[String]("name"))
.out(stringBody)
.handleSuccess(name => s"Hello, $name!")