'How to allow input file filed in swagger

I make a nest application and I try to make an endpoint that allows the user to upload the file and I want the upload file field to show in swagger. This is my function in Controller file:

    @Post('upload')
    @UseInterceptors(FileInterceptor('file'))
    uploadFile(@UploadedFile() file: Express.Multer.File) {
    console.log(file);
    }

But in my swagger UI , it doesn't show the upload file field enter image description here



Solution 1:[1]

Add the following decorator above the action

@ApiImplicitFile({ name: 'file' })

So instead of -

@Post('upload')
@UseInterceptors(FileInterceptor('file'))
uploadFile(@UploadedFile() file: Express.Multer.File) {
console.log(file);
}

change to -

  @ApiImplicitFile({ name: 'file' })
    @Post('upload')
    @UseInterceptors(FileInterceptor('file'))
    uploadFile(@UploadedFile() file: Express.Multer.File) {
    console.log(file);
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 avi siboni