【发布时间】:2020-10-03 18:30:42
【问题描述】:
暂时没有做 API,想确定当您需要在 HttpGet 中传递多个参数时进行调用的最佳做法是什么
选项一
[HttpGet("getpet", Name = nameof(GetPet))]
[ProducesResponseType(typeof(PetResponse), (int)HttpStatusCode.OK)]
public async Task<ActionResult<<PetResponse>> GetById(
[FromQuery]int id,
[FromQuery]bool dogsOnly)
选项 2 使用复杂对象。
[HttpGet("getpet", Name = nameof(GetPet))]
[ProducesResponseType(typeof(PetResponse), (int)HttpStatusCode.OK)]
public async Task<ActionResult<<PetResponse>> GetById([FromQuery]PetRequest request)
公共类 PetRequest { 公共 int ID { 获取;放; } 公共布尔 DogsOnly { 获取;放; } }
对任何方法的任何建议或限制,例如邮递员测试?
【问题讨论】:
标签: asp.net-core asp.net-core-webapi