V2 Basics (Documenting Routes) - SMILEY4/ktor-openapi-tools GitHub Wiki

Some (optional) basic information about a route can be added. See the official OpenAPI Specification (here or here) for more information.

get("hello", {
    tags = listOf("example")
    operationId = "hello"
    deprecated = false
    hidden = false
    summary = "A short summary of what the operation does"
    description = "A verbose explanation of the operations' behavior"
    deprecated = false
    securitySchemeName = "MyBasicAuth"
    securitySchemeName = setOf("MyBasicAuth", "MyTokenAuth")
    protected = true
    request {
        //...
    }
    response {
        //...
    }
}) {
    // handle request...
}
  • tags - A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. These tags will be added to the tags generated by automaticTagGenerator specified in the plugin configuration.
  • operationId - (optional) unique string used to identify the operation. The (case-sensitive) id should be unique among all operations described in the API.
  • deprecated - whether this route is deprecated
  • hidden - whether to include this route in the openapi-spec
  • securitySchemeName - the name of a security mechanism specified in the plugin configuration. If not specified (and none specified with securitySchemeNames), the default name also specified in the plugin configuration will be used. This field only has an effect for protected routes.
  • securitySchemeNames - the names of the possible security mechanisms specified in the plugin configuration. If not specified (and none specified with securitySchemeName), the default name also specified in the plugin configuration will be used. This field only has an effect for protected routes.
  • protected - Specifies whether this operation is protected. If not specified (i.e. "null"), the authentication state of the Ktor route will be used (i.e. whether it is surrounded by an authenticate-block or not).
  • request - grouping for all information about the incoming request. See Request for more information.
  • response - grouping for all information about the outgoing responses. See Responses for more information.