mardi 30 janvier 2018

How to make ktor-swagger work with generics?

I found this solution to generate swagger API docs from ktor routes: https://github.com/nielsfalk/ktor-swagger. However, it doesn't work if the response type contains generics. E.g.:

data class DataWrapper<T>(
    val data: T,
    val additionalInfo: Unit  // useless field, just for an example
)

data class Response(
    val users: DataWrapper<User>,
    val roles: DataWrapper<Role>
)

The only thing I managed to do is generate T as a placeholder for the generic type. Is there a way to patch ktor-swagger to make it "expand" generic types?





Aucun commentaire:

Enregistrer un commentaire