Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Jun 3, 2024 · 1 comment

Comments

@zubairkhakwani
Copy link

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<MediatR.Unit>.

Reproduction Steps:

  1. Define an endpoint with a return type of Task<MediatR.Unit>.
  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<MediatR.Unit>, 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<MediatR.Unit>.

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:

  • NSwag version: 14.0.7.0
  • Previously, I was using Swashbuckle, and it worked correctly with this type of endpoint.
@zubairkhakwani
Copy link
Author

@fauzanzaid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant