SMILEY4 / ktor-swagger-ui

Kotlin Ktor plugin to generate OpenAPI and provide Swagger UI
Apache License 2.0
156 stars 25 forks source link

File Upload feature is not working #58

Closed x2d7751347m closed 1 year ago

x2d7751347m commented 1 year ago

https://github.com/SMILEY4/ktor-swagger-ui/wiki/Request-and-Response-Bodies-Basics

I followed the example in the linked wiki above, However, it is displayed as shown in the picture below.

2

The function I want is like the picture below. How do I fix it?

image

Here is the code.

import java.io.File
...

post({
                request {
                    multipartBody {
                        required = true
                        description = "profile image"
                        mediaType(ContentType.MultiPart.FormData)
                        part<File>("profileImage") {
                            mediaTypes = setOf(
                                ContentType.Image.PNG,
                                ContentType.Image.JPEG,
                                ContentType.Image.GIF
                            )
                        }
                        part<Metadata>("myMetadata")
                    }
                }
            }) {
...
}

build.gradle.kts


...
dependencies {
    implementation("io.ktor:ktor-server-swagger-jvm:2.3.2")
    implementation("io.ktor:ktor-server-openapi:2.3.2")
    implementation("io.github.smiley4:ktor-swagger-ui:2.2.0")
...
}
SMILEY4 commented 1 year ago

Hi, thanks for reporting this issue. The bug is fixed with version 2.2.3 which should be available for download now/soon.