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

Issue on validation when exposing a multipart/form-data API #347

Open
marco-basso opened this issue Mar 6, 2023 · 3 comments
Open

Issue on validation when exposing a multipart/form-data API #347

marco-basso opened this issue Mar 6, 2023 · 3 comments

Comments

@marco-basso
Copy link

The feauture or bug you are proposing

Issue on validating a multipart/form-data request

The description of the bug or the rationale of your proposal

The schema definition of a mutlipart/form-data part requires the following body structure:

{
  additionalProperties: false,
  properties: {
    part: {
      description: 'Binary content of the file to upload',
      format: 'binary',
      type: 'string',
    },
  },
  required: ['part'],
  type: 'object',
}

Calling the endpoint with a binary file uploaded through the part field does return a validation error which states: 'body.part must be string`

The expected result for your bug

I expect that this validation error should not happen

Your environment

node: 8.15.0

custom-plugin-lib: 4.3.2

os: 20.04.5 LTS (Focal Fossa), Ubuntu

@fredmaggiowski
Copy link
Member

fredmaggiowski commented Mar 6, 2023

Hi @marco-basso I'm not entirely sure this is an issue with the library; it seems an issue with @fastify/swagger 🤔

Also consider that node 8 is not supported, you need at least node 12

@marco-basso
Copy link
Author

Sorry, I inserted the wrong version on my issue, the actual node version is v16.17.0.

I do not know if it is an issue with @fastify/swagger since he does its job fine. The problem appears when I try to do a request with a binary file and the validation does not succes because it expect a string. I would argue it could be a problem with ajv compiler or with the fastify ajv plugin.

My current workaround is to avoid to specify the type: string on the body of my request, BUT this does not let me upload a file from the swagger ui because the right specification should contain such type.

@fredmaggiowski
Copy link
Member

I do not know if it is an issue with @fastify/swagger since he does its job fine. The problem appears when I try to do a request with a binary file and the validation does not succes because it expect a string. I would argue it could be a problem with ajv compiler or with the fastify ajv plugin.

Regardless of being a @fastify/swagger or ajv issue I don't think it is a bug of the custom plugin lib or lc39 🤔

The only setup that is done of the libraries related to the openapi specification are:

I'd try to update the library and understand whether this is a bug with @fastify/swagger or ajv and if there is a fix available we could update the libraries :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants