flask-smorest icon indicating copy to clipboard operation
flask-smorest copied to clipboard

Handling multiple dynamic nested query parameters in Flask-Smorest

Open mbernabo opened this issue 1 year ago • 0 comments

Context

I'm trying to handle multiple dynamic filters in query parameters with Flask-Smorest. The query string looks like this:

filters[status][0]=value1&filters[status][1]=value2&filters[type][0]=valueA

Question

What's the recommended way in Flask-Smorest to handle this type of query parameters without manually parsing request.args? Specifically:

  1. Is there a built-in method to automatically parse these into a nested dictionary or list structure?
  2. Can we configure a schema to handle this pattern of parameters?
  3. What's the most idiomatic approach in Flask-Smorest for this scenario?

Desired Outcome

Ideally, I'd like to end up with a structure like this:

{
    "filters": {
        "status": ["value1", "value2"],
        "type": ["valueA"]
    }
}

Any insights or best practices for handling such dynamic, nested query parameters in Flask-Smorest would be greatly appreciated.

mbernabo avatar Oct 09 '24 19:10 mbernabo