https://kotlinlang.org logo
#http4k
Title
# http4k
r

Ray Eldath

02/04/2020, 9:35 AM
hey everyone. is there any way to mark a field as optional in auto-modeled http body message? like, define:
Copy code
data class ApproveRequest(val roleId: Int, val extraPermissions: List<InboundPermission> = emptyList())
and
Copy code
private val requestLens = Body.auto<ApproveRequest>().toLens()
want i want is the field
extraPermissions
will be marked as
optional
instead of
required
in generated OpenApi doc because it have a default value. this may seems somewhat unreasonable, but i just met this in my backend application 😅
d

dave

02/04/2020, 9:38 AM
You should be able to just mark the field as billable in the data class.
😉 1
r

Ray Eldath

02/04/2020, 10:03 AM
thanks! seems marked as nullable and use
null
as default value could fix
2 Views