Skip to content

V1 Documenting Routes

Lukas Ruegner edited this page May 29, 2023 · 1 revision

The Swagger-UI plugin provides functions to create get, put, post, delete, ... routes. These work exactly the same as their respective base Ktor-functions, but allow OpenAPI documentation to be added. Functions to create routes provided by the plugin and those from Ktor can be mixed and allow for a gradual enhancement of the api with documentation.

Documentation can be added to get, post, put, delete, patch, options, head, route and method. If multiple parts in a route have documentation, the documentation is merged with priority given to the last part (Example: the "route" and a nested "get" have a "description" set. When the two documentations are merged, the description of the "get" takes priority).

routing {
    
    route("api", {
        // add api-documentation here...
    }) {
        
        get {
            // handle request...
        }
        
        get("hello", {
            // add api-documentation here...
        }) {
            // handle request...
        }
        
    }
    
}
Clone this wiki locally