Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
809 views
in Technique[技术] by (71.8m points)

How to declare response type as file on nestjs swagger?

I am building a web app with nestjs(typescript). Right now, I am working on swagger, and wonder how I can declare response type as 'file' (this API will return a file as a response)

  @Get('download')
  @ApiBearerAuth()
  @ApiResponse({ status: 200, type: 'file' })
  @ApiOperation({ description: 'file download' })
  async download(@Body() downloadFileDto: DownloadFileDto) {
    //do something and return file
    return;
  }

I've tried this, but I am getting an error:

Resolver error at paths./api/file/download.get.responses.200.content.application/json.schema.$ref
Could not resolve reference: #/components/schemas/
question from:https://stackoverflow.com/questions/65895568/how-to-declare-response-type-as-file-on-nestjs-swagger

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...