Skip to content

22. Examples: Multi‐Part

Perraco edited this page Nov 23, 2024 · 2 revisions
fun Route.uploadDocumentsRoute() {
    post("/api/v1/document") {
        // Implement as usual
    } api {
        tags = setOf("Document")
        summary = "Upload a document."
        description = "Uploads a document into the system storage."
        operationId = "uploadDocument"
        queryParameter<Uuid>(name = "owner_id") {
            description = "The owner of the document."
        }
        requestBody<Unit> {
            multipart {
                part<PartData.FileItem>("file") {
                    description = "The file to upload."
                }
                part<PartData.FormItem>("metadata") {
                    description = "Metadata about the file, provided as JSON."
                }
            }
        }
        response<Uuid>(status = HttpStatusCode.Created) {
            description = "Document created."
        }
        bearerSecurity(name = "Authentication") {
            description = "Access to document storage."
        }
    }
}