Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Striar-Yunis opened this issue Aug 16, 2021 · 0 comments

Comments

@Striar-Yunis
Copy link

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"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant