8000 Proposal - Support Multipart request data via a new annotation · Issue #45 · tabilzad/inspektor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 8000
Proposal - Support Multipart request data via a new annotation #45
Open
@schott12521

Description

@schott12521

Have you ever had to work with multipart data uploads? When used with resource based routing, the route looks like:

post { _: VideoResource.Upload, multipart: MultiPartData ->

Unfortunately this generates a scheme reference in the openapi spec and it doesn't really work as expected. Which is fine, because it doesn't seem like ktor-docs advertises multipart support.

Here is what is generated:

          application/json:
            schema:
              $ref: "#/components/schemas/io.ktor.http.content.MultiPartData"

but it should be something like:

      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                description:
                  type: string
                  description: Video description
                video:
                  type: string
                  format: binary
                  description: Video file to upload
            encoding:
              video:
                contentType: video/mov, video/quicktime, video/gif, image/gif, video/webm

I think the best way to support this is probably via an annotation, because its additional information outside of the ktor request (contentType is at least, so we might as well take it all in via annotation). It would be nice if we could utilize @KtorFieldDescription for the properties in the multipart upload, but it would require a small refactor which would increase its responsibilities.

OpenAPI reference - https://swagger.io/docs/specification/v3_0/describing-request-body/multipart-requests/
Ktor reference - https://ktor.io/docs/server-requests.html#form_data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0