domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.25k stars 1.31k forks source link

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

Open nighttiger1990 opened 4 months ago

nighttiger1990 commented 4 months ago

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

jgarciadelanoceda commented 2 months ago

I do not know really and I have tried several ways.

I do not know what's the correct way to expose this Query parameter so Swagger-Ui formats them in the way you expected, so I suggest you open a Issue on that repo

github-actions[bot] commented 4 days ago

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.