-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use ktor-swagger-ui 2.2.3 to generate openapi-spec that support multi-file upload. #165
Comments
Hi @nartgg35665, try this sample (I copied this one from examples in repo):
|
Hello @RowlenZen , I want the swaggerUI to enable user to select multiple file when clicking choose file button. Right now, I can choose only one. |
Hi @nartgg35665, sorry for the late response. I'm a bit rusty with this version, but I think a possible solution for versions 2.x could look like this: // define a custom json schema for an array of files
TypeOverwrites.entries[getSchemaType<Array<File>>()] = """
{
"type": "array",
"items": {
"type": "string",
"format": "binary"
}
}
""".trimIndent()
install(SwaggerUI)
//...
post("list_of_files", {
request {
multipartBody {
mediaType(ContentType.MultiPart.FormData)
part<Array<File>>("images") { // use array of files as schema -> uses own defined json schema
mediaTypes = setOf(
ContentType.Image.PNG,
ContentType.Image.JPEG,
ContentType.Image.GIF
)
}
}
}
}) {
call.respond(HttpStatusCode.NotImplemented, "...")
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I am using ktor-swagger-ui 2.2.3 . Is there a way to generate openai-spec.json to support multi-file upload.
I did sth like this but it does not work.
The text was updated successfully, but these errors were encountered: