koxudaxi/fastapi-code-generator

No Request parameter generated for `requestBody` with `multipart/form-data`

olivergondza opened this issue · 2 comments

I am describing a schema for uploading files, and hence using multipart/form-data content type for requestBody. The generated function have no argument provided. Note that the request: Request is correctly generated for application/x-www-form-urlencoded content type.

paths:
  /foo:
    put:
      summary: Bar
        requestBody:
        content:
          "multipart/form-data":
            schema:
              type: object
              properties:
                metadata:
                  type: string
                  format: binary
                payload:
                  type: string
                  format: binary

I also need this functionality. My specific use case is allowing clients to upload a file. According to the fastapi docs here, it talks about using the UploadFile and File data types. The recommended approach is to use the UploadFile type.

This library does not yet support the multipart/form-data MIME type for a requestBody. @koxudaxi I'm attempting this but I'm realizing that not all use cases for multipart/form-data will be an UploadFile type. At this point, I'm not sure how to handle this but I'll give a try and see what I come up with.

Opened a PR for atleast supporting fileuploads with application/octet-stream content types. #313