tabilzad / ktor-docs-plugin

Provides Ktor Swagger support
34 stars 6 forks source link

Doesn't seem to detect resource routes #13

Closed ixtli closed 3 months ago

ixtli commented 3 months ago

If you download the ktor starter with the resources plugin and modify it so that it looks like this

fun Application.configureRouting() {
    install(Resources)
    routing {
        misc()
        articles()
    }
}

@Serializable
@Resource("/articles")
class Articles(val sort: String? = "new")

fun Route.misc() {
    get("/") {
        call.respondText("Hello World!")
    }
}

fun Route.articles() {
    get<Articles> { article ->
        // Get all articles ...
        call.respond("List of articles sorted starting from ${article.sort}")
    }
}

annotating the module() function like this

@GenerateOpenApi
fun Application.module() {
    configureHTTP()
    configureRouting()
}

does not produce yaml for Route.articles()

---
openapi: "3.1.0"
info:
  title: "Example"
  description: "Some description here!"
  version: "0.0.1"
paths:
  /:
    get: {}
components:
  schemas: {}

config looks like this

swagger {
    documentation {
        docsTitle = "Example"
        docsDescription = "Some description here!"
        docsVersion = version.toString()
        generateRequestSchemas = true
        hideTransientFields = true
        hidePrivateAndInternalFields = true
        deriveFieldRequirementFromTypeNullability = true
    }

    pluginOptions {
        format = "yaml"
        saveInBuild = true
    }
}
ixtli commented 3 months ago

Oh! I had missed this as a planned feature. Please feel free to consider this a feature request and close it if you want.

tabilzad commented 3 months ago

yeah ktor resources arent supported at the moment. But I'm working on adding the support soon. I'll keep the issue open until then.