Closed CristianMG closed 1 year ago
Hi
the latest version doesn't really have support for this. I just did some experimentation and added some basic features allowing multipart bodies. I havent released or merged it yet, but you can already test it with the version com.github.SMILEY4:ktor-swagger-ui:feature~multipart-body-SNAPSHOT
and see if that works.
You would then descripe the route/body like this
post("example", {
request {
multipartBody {
mediaType(ContentType.MultiPart.FormData)
part<File>("image") {
mediaTypes = setOf(
ContentType.Image.PNG,
ContentType.Image.JPEG
)
}
part<Metadata>("metadata") {
mediaTypes = setOf(ContentType.Application.Json)
}
}
}
}) {
//...
}
//...
data class Metadata(
val format: String,
val location: Coords
)
data class Coords(
val lat: Float,
val long: Float
)
Files seem to work fine, at the moment, I don't need more. Waiting for a release
I think although the library is in the early stage you have a lot of work done it. Congratulations.
Thank you! Version 0.8.0 is released. You can find some information about the multipart-bodies here: https://github.com/SMILEY4/ktor-swagger-ui/wiki/Documenting-Routes-(Bodies)#multipart-bodies
Hi.
I'm using this library to build a template in Ktor, I'm having a problem defining a multipart body. I can't find any information apart from the media types.
Can you help me?
Thanks.