I'm using swagger 2.0.X and akka-http. I want to upload file via swagger ui, but don't know how to describe it into the code.I've tried to use request body with multipart content, but it doesn't works
@POST
@Path("/photo/upload")
@Operation(
summary = "Upload photo",
parameters = Array(
new Parameter(
name = "doctype",
description = "HEADER, describes uploaded document type",
in = ParameterIn.HEADER,
required = true,
schema = new Schema(implementation = classOf[String])
)
),
requestBody = new RequestBody(
description = "file",
content =
Array(new Content(mediaType = "multipart/form-data", schema = new Schema(`type` = "string", format = "binary")))
)
)
def startPhotoUpload: Route = post {
headersMap { headers =>
fileUpload("filename") {
case (_, fileStream) =>
val is = fileStream.runWith(StreamConverters.asInputStream())
handleRequest(
documentUploadServiceActorProps,
SendPhotoToFurtherUpload(is, headers)
)
}
}
}