我有一個項目,我想使用自定義類型的路由屬性。 以下代碼中,我將自定義類型作爲查詢參數運行正常,並且幫助頁面顯示自定義類型。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不會識別該操作。 –