Is it possible for type-safe end points to have se...
# ktor
e
Is it possible for type-safe end points to have sealed type parameters? I get "Expect exactly one parameter with name ..., but found 0".
j
e
I don't see sealed classes mentioned there. Are you saying they are not supported? Let's say I want to use one end point for both long ids and uuids:
Copy code
@Serializable
sealed class IdOrUuid {
    @Serializable
    data class Id(val id: Long) : IdOrUuid()
    @Serializable
    data class Uuid(val uuid: String) : IdOrUuid()
}
Can this type be used as a Resource parameter? I can't seem to, and I would consider it a bug.
s
Something has to determine which subclass to map a given value to right ? (there is no type discriminator) You can argue that it should be built in that it could support your pattern of mixing strings and numbers in a path through a sealed class like that but calling it a bug is maybe stretching it
e
I think you are saying they are indistinguishable in their string form? Is there a way I can use the type system to add that type discriminator?
a
@Emre, the parameters of the resources with sealed class types aren't supported. Feel free to file a feature request.
👍 1
j
@Emre You can use nested classes with parameters