This project has been discontinued. https://github.com/pjfanning/swagger-akka-http-sample demos a different approach to including the swagger-ui in your application.
Support for generating Swagger REST API documentation along with UI for Akka-Http based services.
This module extends swagger-akka-http with the Swagger-UI as webjar.
The jars are hosted on sonatype and mirrored to Maven Central. Snapshot releases are also hosted on sonatype.
Version | Stability | Branch | Description |
---|---|---|---|
2.6.x | stable | main | First release |
libraryDependencies += "com.github.swagger-akka-http" %% "swagger-akka-http-with-ui" % "<release-version>"
Swagger UI depends fully on swagger-akka-http. For more details on usage and background, see README of swagger-akka-http.
gerbrand/swagger-akka-http-with-ui-sample is a simple sample using this project.
The SwaggerHttpWithUiService
is a trait extending SwaggerHttpService
which in turn is extending Akka-Http. It will generate the appropriate Swagger json schema based on a set of inputs declaring your Api and the types you want to expose.
The SwaggerHttpWithUiService
contains a routes
property you can concatenate along with your existing akka-http routes. This will expose an endpoint at <baseUrl>/<specPath>/<resourcePath>
with the specified apiVersion
, swaggerVersion
and resource listing along with the Swagger-UI.
The service requires a set of apiTypes
and modelTypes
you want to expose via Swagger. These types include the appropriate Swagger annotations for describing your api. The SwaggerHttpService
will inspect these annotations and build the appropriate Swagger response.
Here's an example SwaggerHttpWithUiService
snippet which exposes Swagger's PetStore resources, Pet
, User
and Store
. The routes property can be concatenated to your other route definitions:
object SwaggerDocService extends SwaggerHttpWithUiService {
override val apiClasses: Set[Class[_]] = Set(classOf[PetService], classOf[UserService], classOf[StoreService])
override val host = "localhost:8080" //the url of your api, not swagger's json endpoint
override val apiDocsPath = "api-docs" //where you want the the swagger-docs and swagger-json endpoint exposed
override val info = Info() //provides license and other description details
}.routes
See swagger-akka-http-with-ui-sample for a fully working example.
For more information, see README of swagger-akka-http.
If you don't want to include a swagger UI, or want to include the static swagger-UI, use swagger-akka-http instead of this module.