Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Latest commit 97e4ac7 Apr 6, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
ktor-sample-swagger Add support for patch. Include patch in the sample-application. Apr 5, 2019
ktor-swagger Tests for patch Apr 5, 2019
.gitignore Convert Build to Gradle and Bump Ktor version to 0.9.2 Jun 26, 2018
.travis.yml Have travis use --console=plain for readable Gradle logging Jul 10, 2018
LICENSE Added License Jun 6, 2018
Procfile Hopefully fix Heroku Nov 26, 2018 Update Mar 25, 2019 Update to Kotlin 1.3.11 and update Ktor Jan 3, 2019
ktor-swagger-root.gradle.kts Release version 0.5.0 Mar 27, 2019
settings.gradle Initial Commit Aug 22, 2017

ktor with swaggerUi

Build Status Download

This project provides a library that allows you you to integrate the swaggerUi with ktor

An example efrom the ktor-sample-swagger is deployed on heroku.

When using this with Jackson

By default, Jackson includes fields with null values in the JSON output that it generates. This results in swagger.json and openapi.json files that cannot be processed by Swagger UI properly, leading to error messages while parsing the type and format info of parameters. To prevent this, install Jackson content negotiation as follows:

install(ContentNegotiation) {
    jackson {
        // (You can add additional Jackson config stuff here, such as registerModules(JavaTimeModule()), etc.)

Example Usage

This library adds some extension function that build on the ktor routing feature to provide an API that allows this feature to automatically generate a swagger.json file for your webserver.

routing {
    get<pets>("all".responds(ok<PetsModel>())) {
    post<pets, PetModel>("create".responds(created<PetModel>())) { _, entity ->
        call.respond(Created, entity.copy(id = newId()).apply {
    get<pet>("find".responds(ok<PetModel>(), notFound())) { params ->
        data.pets.find { == }
            ?.let {

Project Status

This project is a proof of concept built on a library to support this functionality.

There is an open proposal to include this project as an official Ktor feature here.

You can’t perform that action at this time.