我有一个项目,我想使用自定义类型的路由属性。 以下代码中,我将自定义类型作为查询参数运行正常,并且帮助页面显示自定义类型。ApiExplorer不识别自定义类型的路由属性
// GET api/values?5,6
[Route("api/values")]
public string Get(IntegerListParameter ids)
{
return "value";
}
WebApi.HelpPage提供了以下文件 Help:Page
如果我改变使用路由属性的代码,结果是我得到一个空的帮助页面。
// GET api/values/5,6
[Route("api/values/{ids}")]
public string Get(IntegerListParameter ids)
{
return "value";
}
当我检查我在HelpController.cs观察代码ApiExplorer.ApiDescriptions返回ApiDescriptions的空收集
public ActionResult Index()
{
ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
Collection<ApiDescription> apiDescriptions = Configuration.Services.GetApiExplorer().ApiDescriptions;
return View(apiDescriptions);
}
有没有什么办法让ApiExplorer认识到我的自定义类IntegerListParameter作为属性路由?
我已经实现了用逗号分隔的整数列表。它可以很好地作为查询参数和属性路由。 –
我的问题是,helppage没有显示列表是属性路由的行为。 问题是,当列表实现为属性路由时,ApiExplorer.ApiDescriptions不会识别该操作。 –