Skip to content

Add compatibility for query params with square brackets #5

@frabarz

Description

@frabarz

By default FastAPI has compatibility for lists in query params using multiple duplicates of the same param, without extras: q=1&q=2&q=3, however many client libraries build list parameters into query params adding square brackets to the param name: q[]=1&q[]=2&q[]=3, and even declaring the index of the value inside it if the order of the elements is relevant: q[0]=1&q[1]=2&q[2]=3.
This serialization is not standardized by any RFC, but is widely supported by client libraries like axios, which by default uses the second method here described.

It would be useful to avoid repeating code to integrate this method of parsing directly into LogicLayerModule; this is possible by subclassing the fastapi.Request and fastapi.routing.APIRoute classes. Implementations can then customize their methods by subclassing these or declaring their own Route class on the internal router object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions