Swagger: File upload parameter

Created on 5 Oct 2017  路  4Comments  路  Source: nestjs/swagger

Please add the ability to annotate file parameter.

PRs open feature request

All 4 comments

I would like to develop this topic, because I'm thinking to help and create pull request.
I see couple of options here.

  1. Attach to @UploadedFile decorator and start parsing it's output. This might be not flexible enough. Someone might want to specify exact consumption type of redefine the name.
  2. Extend @ApiImplicitBody decorator with form data settings. This will be confusing, as we will try to redefine actual consumption type.
  3. Extend @ApiConsumes with multi part specific options. Declaration might be over complicated and will break SRP.
  4. Introduce generic @ApiRaw decorator which will consume raw swagger part as string, object (anything). Through this decorator it will be possible to close most of the corner cases, at least until perfect solution will be found.

For now, as there a lot of cases still, I prefer 4th option as it will cover every potential documentation request. It's far from being perfect, but it is good enough to solve business requirements more effectively than keeping swagger documentation up to date in several places.

It's said, that if your application using anything that is not supported by set of default decorators from swagger you are not able to use this module at all then.

@ApiImplicitFile() is available now (v2.5.0)

Btw, @ApiRaw() proposal sounds great as well

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings