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