Skip to content

multipart formdata issue with spec #299

Closed
@Wim-De-Clercq

Description

@Wim-De-Clercq

A schema which contains a path with the following can not be validated with openapi-core.
This relates to #231

      summary: multipart test
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object  # ---This is the issue. 
              properties:
                file:
                  type: string
                  format: binary
                name:
                  type: string

It can be resolved by not using type: object on the commented line. But https://swagger.io/docs/specification/describing-request-body/multipart-requests/ and https://swagger.io/docs/specification/describing-request-body/file-upload/ both give examples of schemas with it.

While it's not a huge deal to workaround, I feel like the library should be able to handle this.

Edit: It seems that without the object type, the validation just does not work. (I tried using an enum in the properties, and they are not validated).

I do see https://github.com/p1c2u/openapi-core/blob/b51d8104ac1fee1d99ff4a51caedf138e50ccb27/openapi_core/deserializing/media_types/factories.py#L8-L12

Does that mean there is only json support at the moment?


As a sidenote, the resulting "body" from validating formdata is quite raw (just a bytestring), I wonder if this could return something that's parsed a little bit more, but I do realise that multipart formdata is not the easiest thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions