fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
941 stars 209 forks source link

Enhance fileupload UI for multipart/form-data #667

Open imjuni opened 2 years ago

imjuni commented 2 years ago

Prerequisites

🚀 Feature Proposal

As a first, Great thank you for good tools. I suggest to enhance swagger ui for fileupload. Recently OpenAPI 3.0 support filpupload widget below,

filewidget

from: https://swagger.io/docs/specification/describing-request-body/file-upload/

But I cannot found documentation that display fileupload widget on @fastify/multipart and @fastify/swagger.

So I test 4 way of usage.

Expectation

I think that display fileupload widget and validate using by sharedSchemaId in @fastify/multipart. Or I want to know best practice for file upload and swagger.

Environment

Package Version
@fastify/multipart ^7.1.2
@fastify/swagger ^7.5.1
fastify ^4.5.3
fastify-plugin ^4.2.1
ajv ^8.11.0
ajv-formats ^2.1.1
node 16.17.0
npm 8.15.0
os win32, macOSX

Motivation

Better develop experience provide to co-worker or consumer.

Example

I upload sample project my repo.

  1. Checkout feature/fileupload
  2. Install package: npm install
  3. Run development server: npm run dev
  4. open url on browser: http://localhost:17878

Finally you can see like that: swagger_fileupload_widget02

mcollina commented 2 years ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.