@Serializable
sealed interface NewUser {
val username: String
val password: String
/**
* List of role id's to add to the user.
*/
val roles: List<Long>?
@Serializable
data class NewUserDto(
override val username: String,
override val password: String,
override val roles: List<Long>? = null,
val relation: RelationDto,
) : NewUser
@Serializable
data class NewUserWithRelationDto(
override val username: String,
override val password: String,
override val roles: List<Long>? = null,
/**
* The id of the existing relation to add to this user
*/
val relation: Long
) : NewUser
}
The route documentation
val postUserDocumentation : RouteDocumentation
get() = {
tags = setOf(TAG)
description = "Create new user"
securitySchemeNames = setOf("Kargro_Identity")
response {
HttpStatusCode.OK to Unit
}
request {
body<NewUser>()
}
}
I am missing the option to add a discriminator property to a body that can contain anyOf a specified sealed interface.
this is the body code i am using and cannot find any possibility to add the discriminator property as descript in the openApi spec: https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/#:~:text=or%20complexObject.-,Discriminator,-To%20help%20API
The sealed interface
The route documentation