What is the correct way to download a file via the NSwag Code Generator (angular 2 typescript)

后端 未结 4 1794
盖世英雄少女心
盖世英雄少女心 2021-02-13 16:50

I try to download a file via an angular 2 typescript client. The link generated in Swagger UI works fine, but the generated typescript client does not.

The controller lo

4条回答
  •  灰色年华
    2021-02-13 17:50

    Found the response of this problem :

    In startup add :

    services.AddSwaggerGen(options =>
    {   
    options.MapType(() => new Schema
           {
                    Type = "file",
                });
    }
    

    And for your controller :

    [HttpPost()]
        [SwaggerResponse(200, typeof(FileContentResult))]
        [ProducesResponseType(typeof(FileContentResult), 200)]
        public async Task MyMethod(Viewmodel vm)
        {
    

    A late response but for people who has the same problem ...

提交回复
热议问题