我具有OData功能:
public class ItemsController : ODataController
{
[HttpGet]
public async Task<IHttpActionResult> SomeFunc([FromODataUri]SomethingDTO something)
{
return Ok(1);
}
}
SomethingDTO:
public class SomethingDTO
{
public int Name { get; set; }
}
和ODataConfig:
public static class WebApiConfig
{
public static void Configure(HttpConfiguration config)
{
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EnableLowerCamelCase();
builder.EntitySet<Item>("Items");
var itemsEntityType = builder.EntitySet<Item>("Items").EntityType;
var func = itemsEntityType.Collection.Function("SomeFunc");
func.Parameter<SomethingDTO>("something");
func.Returns<int>();
config.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());
}
}
这工作正常,但是当我打开打开页面时,应用程序引发异常:在Swashbuckle.OData.dll中发生类型为'System.ArgumentOutOfRangeException'的异常,但未在用户代码中处理 ParameterName:TypeKind
当我从OData配置中删除此字符串func.Parameter<SomethingDTO>("something");
时,Swagger页面可以正常工作。但是OData功能出现故障。
如何在Swashbuckle.OData中为OData函数定义复杂的参数?
.NET 4.5.2
Microsoft.AspNet.OData版本=“ 6.0.0”
Swashbuckle version =“ 5.6.0”
Swashbuckle.Core版本=“ 5.6.0”
Swashbuckle.OData版本=“ 3.5.0”