Reputation: 133
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
Upvotes: 0
Views: 710
Reputation: 814
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);
}
Upvotes: 1