Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nighttiger1990 opened this issue Jul 5, 2024 · 2 comments
Labels
question stale Stale issues or pull requests

Comments

@nighttiger1990
Copy link

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
Copy link
Contributor

jgarciadelanoceda commented Sep 4, 2024

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

  • Set the style "form"
  • Set the style "form" and explode true (This is not supported in OpenApi.Net but I tricked it with app.MapGet exposing the OpenApi document with the properties I wanted)
  • Set the style "deepObject"
  • Set the style "deepObject" and explode true
  • Set the Content as multipartFromData and the schema inside the item

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

Copy link
Contributor

github-actions bot commented Nov 4, 2024

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.

@github-actions github-actions bot added the stale Stale issues or pull requests label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question stale Stale issues or pull requests
Projects
None yet
Development

No branches or pull requests

2 participants