0
當使用ASP.NET WebApi2和Swashbuckle /揚鞭,我試圖綁定使用FromUri屬性是這樣的一個對象,:使用FromUri綁定對象不帶參數的名稱前綴
[RoutePrefix("api/v1/example")]
public class ExampleController : ApiController
{
[HttpGet]
[Route("{id}")]
public ExampleModel Get(string id, [FromUri]ExampleModel searchCriteria)
{
...
}
}
public class ExampleModel
{
public string id { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
}
我發現URL按姓氏執行此GET操作和搜索最終是這樣的:
http://localhost:52259/api/v1/example/1?searchCriteria.firstName=paul
我怎樣才能把查詢參數的「searchCriteria」前綴?我想保持它作爲控制器的方法簽名的ExampleModel對象,但可以使用(並有這樣的反映在揚鞭UI文檔):
http://localhost:52259/api/v1/example/1?firstName=paul