Forum Discussion

cargt3's avatar
cargt3
Occasional Visitor
6 years ago

How to pass array of objects using query string in SwaggerUI

How to pass array of objects using query string in SwaggerUI? When i use PostManwith query http://localhost:50353/contacts/filter?filters[0].PropertyName=name&filters[0].Operator=Equal&filters[0].Value=18 it works properly but when i use SwaggerUI it bind empty model and pass query string like this: {?Filters=filters%5B0%5D.PropertyName%3Dname%26filters%5B0%5D.Operator%3DEqual%26filters%5B0%5D.Value%3D18&Filters=}

 

    [HttpGet]
    [Route("/contacts/filter")]
    [ValidateModelState]
    [SwaggerOperation("PostContactFilter")]
    [SwaggerResponse(statusCode: 200, type: typeof(List<Contact>), description: "Successful contact request")]
    [SwaggerResponse(statusCode: 204, type: typeof(Contact), description: "No content")]
    public virtual IActionResult GetContacts([FromQuery]FiltersModel filtersModel)
    {
        var result = _logic.GetContacts(filtersModel);
        if (result is null || result.Count == 0)
            return NoContent();
        else
            return Ok(result);
    }
No RepliesBe the first to reply