Skip to content

Regression? Express + OpenAPI 3.0 + Multer + multipart/form-data rejects valid file #165

@Striar-Yunis

Description

@Striar-Yunis

Reproduction

Note: I have created a minimal reproducible example in CodeSandBox. To use this example:

  • Navigate to CodeSandBox and it will start the container
  • Use a local zip file and the address bar of the rendered CodeSandBox browser to fill out the following curl
  • curl -X POST --form 'core=@/home/...YOUR_PATH.../core' https://GET_URL_FROM_ADDRESS_BAR/example

System Description

  • OS: Ubuntu 20.04.2 LTS
  • Node Latest LTS

Issue Description

The validation middleware isn't accepting files that are defined in the OpenAPI yaml. The files are correctly parsed by multer but they are marked as extra.

Swagger

openapi: 3.0.3
info:
  title: Swagger 3 File Upload Fails
  description: Why doesn't this work?
  version: "1.0"
paths:
  /example:
    post:
      summary: This displays
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                core:
                  type: string
                  format: binary
      responses:
        default:
          description: Doesn't matter

OpenApiValidator Config

{
  framework: "express",
  beautifyErrors: true,
  expectFormFieldsInBody: true
}

Curl

curl -X POST --form 'core=@/home/...YOUR_PATH.../core' https://GET_URL_FROM_ADDRESS_BAR/example

The Error

["body/files Extra files are not allowed. Not allowed files: core"]

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