Skip to content

InspeKtor Logo

InspeKtor

Generate OpenAPI specifications from your Ktor code at compile time.
Zero runtime overhead. Full type safety. Always in sync.

Build Status Maven Central Kotlin License

Get Started View on GitHub


Why InspeKtor?

  • Zero Runtime Overhead


    Documentation is generated at compile time, not runtime. Your application performance stays completely unaffected.

  • No third-party DSL


    Leverages Ktor's standard syntax to generate route definitions and Kotlin's type system to derive schemas.

  • Minimal Annotations


    Most information is inferred from your code. Add annotations only when you need extra documentation.

  • Always In Sync


    Your documentation is generated from actual code, so it's always accurate and never drifts out of date.


Quick Start

1. Add the Plugin

build.gradle.kts
plugins {
    kotlin("jvm") version "2.3.0"
    id("io.ktor.plugin") version "3.0.0"
    id("io.github.tabilzad.inspektor") version "0.10.0-alpha"
}

swagger {
    documentation {
        info {
            title = "My API"
            version = "1.0.0"
        }
    }
}

2. Annotate Your Routes

Application.kt
@GenerateOpenApi
fun Application.module() {
    routing {
        route("/api/users") {

            @KtorDescription(summary = "List all users")
            get {
                responds<List<User>>(HttpStatusCode.OK)
                // Implementation
            }

            @KtorDescription(summary = "Create user")
            post {
                responds<User>(HttpStatusCode.Created)
                responds<ErrorResponse>(HttpStatusCode.BadRequest)
                val request = call.receive<CreateUserRequest>()
                // Implementation
            }
        }
    }
}

3. Build

Bash
./gradlew build

Your OpenAPI spec is generated at build/resources/main/openapi/openapi.yaml


Features at a Glance

Feature Description
Route Detection Automatically detects routes from Ktor's routing DSL
Schema Generation Generates schemas from Kotlin data classes
Request Bodies Infers request schemas from call.receive<T>()
Response Types Documents responses with the responds<T>() function
Path Parameters Detects parameters from {param} syntax
Query Parameters Extracts query parameters from code
KDoc Integration Extracts descriptions from KDoc comments
Security Schemes Supports JWT, API Key, OAuth2, and more
Sealed Classes Full support for polymorphic types with discriminators
Generic Types Handles generic wrappers like Response<T>
Incremental Builds Configurable regeneration modes for fast builds

Explore the Docs

  • Getting Started


    Install InspeKtor and generate your first API spec in minutes.

    Installation

  • Configuration


    Customize API info, security schemes, type mappings, and more.

    Configuration

  • Usage Guide


    Learn how to document endpoints, responses, and parameters.

    Usage Guide

  • API Reference


    Complete reference for annotations, functions, and Gradle DSL.

    API Reference