domaindrivendev/Swashbuckle.AspNetCore

[Question]: How to tell SwaggerUI using "Standard Query Parameters" instead of "JSON-encoded Query Parameters" with GET method?

nighttiger1990 opened this issue · 0 comments

What are you wanting to achieve?

I have an endpoint like this:

public async Task GetExaminationRegisterPayments([FromQuery] List<FilterItem> filterModel){
  //do something
}
public class FilterItem
{
    public string Field { get; set; }
    public string Value { get; set; }
    public string Operator { get; set; }
}

That endpoint work successfully with this Url (Chat GPT tell this mean Standard Query Parameters )

https://localhost:5000/api/test?filterModel[0].field=refId&filterModel[0].value=123&filterModel[0].operator===

But when I used SwaggerUI
image
image

That endpoint work but value of filterModel always is Empty with this Url (ChatGPT tell this mean JSON-encoded Query Parameters)

https://localhost:5000/api/test?filterModel=%7B%0A%20%20%22field%22%3A%20%22refId%22%2C%0A%20%20%22value%22%3A%20%22123%22%2C%0A%20%20%22operator%22%3A%20%22%3D%3D%22%0A%7D

How to tell SwaggerUI using "Standard Query Parameters" instead of "JSON-encoded Query Parameters"?

What code or approach do you have so far?

public async Task GetExaminationRegisterPayments([FromQuery] List<FilterItem> filterModel){
  //do something
}
public class FilterItem
{
    public string Field { get; set; }
    public string Value { get; set; }
    public string Operator { get; set; }
}
https://localhost:5000/api/test?filterModel[0].field=refId&filterModel[0].value=123&filterModel[0].operator===
https://localhost:5000/api/test?filterModel=%7B%0A%20%20%22field%22%3A%20%22refId%22%2C%0A%20%20%22value%22%3A%20%22123%22%2C%0A%20%20%22operator%22%3A%20%22%3D%3D%22%0A%7D

Additional context

No response