express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

multipart/form-data with application/json field doesn't work

Open tamis-laan opened this issue 2 years ago • 2 comments

Given a route specification with the following request body:

   requestBody:
     required: true
     content:
       multipart/form-data:
         schema:
           type: object`
           required:
             - image
             - json
           properties:
             image:
               type: string
               format: binary
             json:
               $ref: '#/components/schemas/MySchema'
         encoding:
           image:
             contentType: image/*
           json:
             contentType: application/json

I get the following error:

request.body.json should be object {
  "errors":[{
    "errorCode":"type.openapi.validation",
    "message":"should be object",
    "path":".body.json"
  }],
  "name":"Bad Request",
  "status":400
}

tamis-laan avatar Mar 05 '22 10:03 tamis-laan

I facing the same issue :( Is there a fix?

diaes avatar Feb 17 '23 14:02 diaes

See this issue for a workaround :

https://github.com/cdimascio/express-openapi-validator/issues/820

fredbonin avatar Mar 01 '23 17:03 fredbonin