I wrote a new method into my Controller of my ASP.Net MVC project and getting error below. I think InvalidOperationException coming from with Swagger. I marked
Another possible solution is to nest the complex data types in a tuple:
[ApiExplorerSettings(IgnoreApi = true)]
public decimal CalculatePriceWithCampaign((BeverageCapacityCampaign campaign, BeverageCapacity capacity) data, int count = 1)
{
switch (data.campaign.DiscountType)
{
case DiscountType.Fixed:
return (data.capacity.CapacityPrice - data.campaign.DiscountValue) * count;
case DiscountType.Percentage:
return (data.capacity.CapacityPrice * count) * data.campaign.DiscountValue;
default:
return data.capacity.CapacityPrice;
}
}
However, NSwag (Swagger) does not seems to be able to automatically parse this case because a non-valid example gets generated. NSwagStudio recognizes the case correctly and generates valid client code.