tabilzad/ktor-docs-plugin

Path as a function

Opened this issue · 1 comments

Hi
I use a function to get the base name for the route. When generating the open API.yaml, the function name is included in the path instead of the function's result.

@GenerateOpenApi
fun Application.configureRouting() {
    routing {
        route(getBaseRoute()) {
fun getBaseRoute(): String {
    val version =  Config.version.split(".")[0]
    return  "/api/v$version"
}

The result Swagger page is
Screenshot 2024-11-15 at 15 03 04

And I expect

Screenshot 2024-11-15 at 15 04 05

Is this something you can fix?

Thank you for this plugin. It is exactly what I was looking for.

Unfortunately, this wouldn't really be possible per kotlin compiler design. The plugin can only evaluate compile time constants but not expressions. There is hope that kotlin would potentially support constant expressions so we could evaluate the literal output at compile time but as of now we are limited to constants only.