Skip to content

Swagger UI

Library for Ktor applications to serve Swagger UI - visualize and interact with generated OpenAPI specifications.

Features

  • Explore and interact with OpenAPI specifications generated by ktor-openapi or external specifications
  • Serve bundled Swagger UI
  • Expose multiple "instances" of Swagger UI (e.g. for different OpenAPI specifications)
  • All Swagger UI configuration options available

Example

routing {

    route("swagger") { //(1)!
        swaggerUI("/api.json") { //(2)!
            //...(3)
        }
    }

}
  1. Specify route to serve Swagger UI at /swagger.
  2. Expose Swagger UI using OpenAPI specification at /api.json. Path can be relative pointing to specification provided by this application or absolute pointing to an external resource.
  3. Add configuration for this Swagger UI "instance" here.