RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.81k stars 1.3k forks source link

Issue with NSwag v14.0.7.0: Swagger not loading and C# client code not generating for endpoints returning Task<MediatR.Unit> #4906

Open zubairkhakwani opened 5 months ago

zubairkhakwani commented 5 months ago

I'm currently using NSwag v14.0.7.0 in my project, and I've encountered an issue where Swagger does not load and the C# client code is not generated for endpoints returning Task.

Reproduction Steps:

  1. Define an endpoint with a return type of Task.
  2. Attempt to load Swagger UI or generate C# client code using NSwag.

Expected Behavior:

Swagger UI should load successfully, and C# client code should be generated for endpoints returning Task, similar to how it worked with Swashbuckle.

Actual Behavior:

Swagger UI does not load, and C# client code is not generated for endpoints returning Task.

Code Snippet:

[HttpPost]
public async Task<BaseResponse<Unit>> Create([FromBody] InvoiceDetail invoiceDetail)
{
  var result = await _mediator.Send(new CreateInvoiceDetailCommand { InvoiceDetail = invoiceDetail });
    return result;
}

[HttpPost]
public async Task<Unit> Create([FromBody] InvoiceDetail invoiceDetail)
{
  var result = await _mediator.Send(new CreateInvoiceDetailCommand { InvoiceDetail = invoiceDetail });
    return new MediatR.Unit();
}

Additional Information:

zubairkhakwani commented 5 months ago

@fauzanzaid